Query Posts From Multiple Post Types
Query Posts From Multiple Post Types
Query Posts From Multiple Post Types
Creating a new CPT adds a dedicated admin menu for managing posts of that type, not a new post format. Those are two different concepts, post format is used to add some meta information on the content of a single post while CPTs are used to create different classes of posts.
wp_set_object_terms not working in functions.php with custom taxonomy
You could do (untested): if( get_post_type($post->post_parent) == ‘apples’ ){ get_template_part(‘single-apple-child’) } else { /* the rest of your current single page */ } Though there may be a better way!
pre_get_posts the right hook you need to use. function CPT_set_default_orderby($q){ global $pagenow, $typenow; if( is_admin() && ‘edit.php’ == $pagenow && ‘post’ == $typenow && !isset($_GET[‘orderby’]) ){ // to order by title $q->set(‘orderby’, ‘title’); // to orderby with meta key $q->set(‘orderby’, ‘meta_key’); $q->set(‘meta_key’, ‘expiration’); } } add_action(‘pre_get_posts’, ‘CPT_set_default_orderby’);
post_parent is a numerical value field in $post object. So you should check if there’s a valid number. Try this – <?php if ( $post->post_parent > 0 ) { ?> the child single-artists.php <?php } else { ?> the parent single-artists.php <?php } ?>
If I assign a featured image to any post in question then it does show the correct image. I just don’t understand why every post after the first twelve are using another posts featured image. I think the problem is that you do not reset $image if the current post doesn’t have a featured thumbnail. … Read more
After some Google searches, I found all I needed to do was set the custom_post_type registration to include hierarchical => true and this solved my problem.
I believe that WPPizza Categories is coming from ‘name’ => _x( ‘WPPizza Categories’, ‘taxonomy general name’ ) And your url problem is coming from not setting a slug. For example: ‘rewrite’ => array( ‘slug’ => ‘pizza_categories’, ‘with_front’ => false ), You need to replace the slug with something else, as you need something in place … Read more
If you load a file directly none of the WordPress functions will work. That is why you should nearly always use the AJAX API. The AJAX API solves this problem. Everything loads in WordPress context. You would wrap your processing PHP is a function: function my_ajax_cb_wpse_108143() { $cote = get_post_meta($_POST[‘id’], ‘cote’, true); if($_POST[‘cote’] == ‘like’) … Read more