Вывод заданного количества постов в определенной категории
https://gist.github.com/robneu/6513742
Set the number of posts per page in all WordPress category archives using pre_get_posts.
1155
0
Set the number of posts per page in all WordPress category archives using pre_get_posts.
<?php
add_action( 'pre_get_posts', 'prefix_category_query' );
/**
* Customize category query using pre_get_posts.
*
* @author FAT Media <http://youneedfat.com>
* @copyright Copyright (c) 2013, FAT Media, LLC
* @license GPL-2.0+
* @todo Change prefix to theme or plugin prefix
*
*/
function prefix_category_query( $query ) {
if ( $query->is_main_query() && ! $query->is_feed() && ! is_admin() && is_category() ) {
$query->set( 'posts_per_page', '10' ); //Change this number to anything you like.
}
}
Comments