jeudi 26 février 2015

pre_get_posts having no effect on my category archive


By default, site is set to show 4 posts per page, but on a particular category (id 76) archive I want it to show 12. I've included this code in functions.php but it's not working. What am I missing here:



add_action('pre_get_posts','filter_archive');
function filter_archive( $query ) {
if ( ! is_admin && is_category('76') && $query->is_main_query() ) {
$query->set('posts_per_page', '12');
}
return $query;
}




Aucun commentaire:

Enregistrer un commentaire