[Support request] Quantity of Posts Showing under Category Tab

Home Forums Support [Support request] Quantity of Posts Showing under Category Tab

Home Forums Support Quantity of Posts Showing under Category Tab

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1615089
    Jeremy

    Hi,

    My I have buttons set up to allow the reader to navigate to a certain category.

    I have noticed that for my blog page I can adjust the amount of posts that are shown before you have to click through to the next page. For the Category, if the button is selected, it goes to that page but only shows 10 posts [no additional pages to click through].

    How do i change the number of posts shown and also ‘next page’ option.

    Regards

    #1615162
    Elvin
    Staff
    Customer Support

    Hi,

    You can control the number of posts shown on the category archive pages specifically by adding this PHP snippet:

    function category_archive_post_per_page( $query ) {
        if ( !is_admin && $query->is_category() && $query->is_main_query() ) {
             $query->set( 'posts_per_page', '6' );
             $query->set( 'orderby', 'date' );
        }
    }
    add_action( 'pre_get_posts', 'category_archive_post_per_page' );

    Here’s how to add PHP: https://docs.generatepress.com/article/adding-php/

    You can change the post_per_page value from 6 to your preferred number of posts per page.

    …also ‘next page’ option.

    The previous, next and pages buttons should automatically render unless you’re using a child theme template that doesn’t have this.

    A wise man once said:
    "Have you cleared your cache?"

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.