Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

according with Pagination with custom loopPagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used:

add_action( 'pre_get_posts', 'wpse5477_pre_get_posts' );
function wpse5477_pre_get_posts( &$wp_query )
{
    if ( $wp_query->is_category() ) {
        $wp_query->set( 'post_type', 'game' );
        $wp_query->set( 'posts_per_page', 9 );
    }
}

I have the section on the main page of my site, where displayed three game from each category. But according with code above I can't display only 3 games, even if I determine in array('post_per_page', 3) or smth like this, because this number have been already determine in $wp-query. how could I kill two birds with one stone? Thanks.

according with Pagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used:

add_action( 'pre_get_posts', 'wpse5477_pre_get_posts' );
function wpse5477_pre_get_posts( &$wp_query )
{
    if ( $wp_query->is_category() ) {
        $wp_query->set( 'post_type', 'game' );
        $wp_query->set( 'posts_per_page', 9 );
    }
}

I have the section on the main page of my site, where displayed three game from each category. But according with code above I can't display only 3 games, even if I determine in array('post_per_page', 3) or smth like this, because this number have been already determine in $wp-query. how could I kill two birds with one stone? Thanks.

according with Pagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used:

add_action( 'pre_get_posts', 'wpse5477_pre_get_posts' );
function wpse5477_pre_get_posts( &$wp_query )
{
    if ( $wp_query->is_category() ) {
        $wp_query->set( 'post_type', 'game' );
        $wp_query->set( 'posts_per_page', 9 );
    }
}

I have the section on the main page of my site, where displayed three game from each category. But according with code above I can't display only 3 games, even if I determine in array('post_per_page', 3) or smth like this, because this number have been already determine in $wp-query. how could I kill two birds with one stone? Thanks.

Source Link
glazsasha
  • 111
  • 2
  • 10

Display different number of posts from one category on the different pages

according with Pagination with custom loop. I use the custom loop for display flash game. For make a pagination on the page with posts from one category (mydomain/category/categoryName) I used:

add_action( 'pre_get_posts', 'wpse5477_pre_get_posts' );
function wpse5477_pre_get_posts( &$wp_query )
{
    if ( $wp_query->is_category() ) {
        $wp_query->set( 'post_type', 'game' );
        $wp_query->set( 'posts_per_page', 9 );
    }
}

I have the section on the main page of my site, where displayed three game from each category. But according with code above I can't display only 3 games, even if I determine in array('post_per_page', 3) or smth like this, because this number have been already determine in $wp-query. how could I kill two birds with one stone? Thanks.