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.

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

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, privacy policy and cookie policy

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