• I currently have 10 posts set up to be displayed on my homepage, which I would like to stay as 10. I did this using the settings in the wordpress panel. However on categories I would like it display 12.

    Does anyone know how would I go about doing this? Im wondering if in the ‘if posts’ statements I have to put in an amount somehow there? Or perhaps in the function.php file?

    Thanks,
    megan

Viewing 1 replies (of 1 total)
  • function posts_per_page_in_cat_archive( $query ) {
        if( ! is_admin() && $query->is_main_query() && $query->is_category() )
            $query->set( 'posts_per_page', '12' );
    }
    add_action( 'pre_get_posts', 'posts_per_page_in_cat_archive' );

    Try to add this code into functions.php of active theme.

Viewing 1 replies (of 1 total)
  • The topic ‘Different number of posts shown on categories page compared to index’ is closed to new replies.