Created
November 23, 2011 21:31
-
-
Save moimikey/1389985 to your computer and use it in GitHub Desktop.
a more proper way to display posts from a specific category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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