Skip to content

Instantly share code, notes, and snippets.

@moimikey
Created November 23, 2011 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moimikey/1389985 to your computer and use it in GitHub Desktop.
Save moimikey/1389985 to your computer and use it in GitHub Desktop.
a more proper way to display posts from a specific category
<?php
add_filter( 'parse_query', 'hertzberg_filter_posts' );
/**
* Hook into parse_query to only return display posts from category id #1 in search & blog/index
*
* @access public
* @return void
*/
function hertzberg_filter_posts( $query ) {
if( is_search() || is_home() )
$query->query_vars['cat'] = 1;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment