check_admin_referer not working in custom meta box for custom post type

Now in saving function … in which hook ? if you do this in “save_post_CPT”, it doesn’t work because this hook is called a first time a the object creation then you have to do this : add_action(“save_post_CPT”, function ($object_ID, \WP_Post $object, $update) { if (!$update) { // new object, here you can define default … Read more

Display child posts from a certain category

You can use the post_parent argument for the query. Here is a slightly modified version of your code: <ul class=”podcasts”> <?php global $post; $catquery = new WP_Query( ‘cat=7&posts_per_page=30&order=DESC&post_parent=” . $post->ID ); while($catquery->have_posts()) : $catquery->the_post();?> <li class=”track-list-item”><?php the_content();?></li> <?php endwhile; wp_reset_postdata(); ?> </ul>

Multiple Custom Post Type with different Taxonomies

Try this: function post_type_categories() { $field_args = array( ‘labels’ => array( ‘name’ => ‘Categories’, ‘taxonomy general name’, ‘singular_name’ => ‘Category’, ‘taxonomy singular name’, ‘search_items’ => ‘Search categories’, ‘all_items’ => ‘All categories’, ‘parent_item’ => ‘Parent category’, ‘parent_item_colon’ => ‘Parent category:’, ‘edit_item’ => ‘Edit category’, ‘update_item’ => ‘Edit category’, ‘add_new_item’ => ‘Add new category’, ‘new_item_name’ => ‘New … Read more

Display posts on parent post if author coincides

I found it (easy one): In functions.php: // Allow author for custom post function allowShowAuthor() { add_post_type_support( ‘cust_post-type’, ‘author’ ); } add_action(‘init’,’allowShowAuthor’); In the content template: <ul class=”author-posts”> <?php $current_page_author = get_the_author(); $catquery = new WP_Query( ‘cat=7&posts_per_page=30&order=DESC&author_name=” . $current_page_author ); while($catquery->have_posts()) : $catquery->the_post(); ?> <li class=”author-post”><?php the_content();?></li> <?php endwhile;?>

Not Able to List CPT Based on Taxonomy Term

Check this code: <?php $custom_terms = wp_get_post_terms($post->ID, ‘service_tax’); $count = count($custom_terms); if ( $count > 0 ) { foreach($custom_terms as $custom_term) { $args = array(‘post_type’ => ‘services_cpt’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘service_tax’, ‘field’ => ‘slug’, ‘terms’ => $custom_term ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { echo ‘<div class=”col-md-4″>’; echo ‘<a class=”item-box” … Read more

wp_nav_menu doesn’t seem to work on custom post type pages

You can just add these parameters in array variable and pass this to wp_nav_menu() Like: function get_menu_params(){ $defaults = array( ‘menu’ => ‘Primary Menu’, ‘theme_location’ => ‘primary’, ‘depth’ => 3, ‘container’ => ‘div’, ‘container_class’ => ‘a’, ‘container_id’ => ‘b’, ‘menu_class’ => ‘nav navbar-nav’, ‘fallback_cb’ => ‘wp_bootstrap_navwalker::fallback’, ‘walker’ => new wp_bootstrap_navwalker() ); return $defaults; } and … Read more