I want to remove a custom post type post from it's archive feed only. But keep in the main feed.
Like is I have1) main feed: myexample/feed2) Custom post type Archive Feed: myexample/mytype_archive/feed
And a custom post named "How are you?" I want to show the post to main feed marked as (1) but hide on post type archive feed marked by (2)
This is what I tried till now:
function archive_exclude_post($query) { if($query->is_feed() && $query->is_archive()){ $query->set('post__not_in', array(40, 9) ); } return $query;}add_filter( 'pre_get_posts', 'archive_exclude_post' );
Not worked for me .Help me to fix the issue please.