Displaying posts from a Custom Post Type on my blog but want to exclude Taxonomy
-
Hoping somebody can help me, been searching with no luck thus far.
I have a Custom Post Type I created called photo-day. I wanted to have the new posts that are added to this appear on my main blog feed along with all my regular blog posts. I was able to accomplish that by adding the following code to my functions.php file. It works great and pulls all the posts from that custom post type onto my blog page.
add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if (( is_home() && false == $query->query_vars['suppress_filters'] ) || is_feed() ) $query->set( 'post_type', array( 'post', 'photo-day' ) ); return $query; }
To make this work exactly how I need it to, I would like to be able to exclude certain posts from appearing on the blog. I created a taxonomy that is attached to this custom post type which is called subject. I am wondering if I can modify the code above to only display posts that are tagged “featured” in the “Subject” taxonomy. Or even exclude posts that are tagged “not-featured” in the “Subject”. Either way is fine, just hoping one is possible ??
Thanks!
- The topic ‘Displaying posts from a Custom Post Type on my blog but want to exclude Taxonomy’ is closed to new replies.