Created
August 23, 2011 16:39
-
-
Save adamharley/1165785 to your computer and use it in GitHub Desktop.
WP categories on home (blog) page
This file contains 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 | |
function category_homepage( $query ) { | |
if ( $GLOBALS['wp_the_query'] != $query || ! $query->is_home() ) // Only filter the main query on the blog page | |
return; | |
$categories = array( 1, 2, 3 ); | |
$query->set('category__in', $categories); | |
} | |
add_action( 'pre_get_posts', 'category_homepage' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment