Exclude posts from Archive
-
I am trying to exclude some posts from showing up in a category archive
The code below I would have thought would exclude the post with id 35385 but it returns no posts at all on the archive. Removing the – in front of the 35385 returns only the post I am trying to exclude. So how come it does not work the other way around and how do I do it?
function exclude_post( $query ) { if ($query->is_archive) { $query->set( 'p', -35385 ); return; }//end if }//end function add_action( 'pre_get_posts', 'exclude_post' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Exclude posts from Archive’ is closed to new replies.