Wordpress: Removing posts in "The Loop" using filters Wordpress: Removing posts in "The Loop" using filters wordpress wordpress

Wordpress: Removing posts in "The Loop" using filters


You can hook into 'pre_get_posts'.More info here: http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts. As the article describes:

This hook is called after the query variable object is created, but before the actual query is run.

Using query_posts(), you can override the query variables and exclude any posts. The link has some decent examples on how to do this.


So you want to remove it from displaying but still have it 'there' incase you decide to show it later? Not really clear on what you want to do.

As one example, in the past I've used Query Posts to keep categories off of my homepage: http://codex.wordpress.org/Template_Tags/query_posts#Exclude_Categories_From_Your_Home_Page