0

I want to remove a custom post type post from it's archive feed only. But keep in the main feed.

Like is I have 1) main feed: myexample/feed 2) 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.

2
  • what do you mean "custom post type post"?
    – Jevuska
    Commented Apr 8, 2016 at 5:28
  • Resolved using @dg4220 's instruction... Commented Apr 11, 2016 at 20:58

1 Answer 1

0

I think this may be what you need - customizing feeds Feed templates are in wp-includes. It's pretty straight forward from there to edit a loop to exclude a post or create a new feed template for the custom post type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.