Site logo

Archived topic

Homepage & Categories: 2 columns layout and featured article.

6 replies · Started by Atty on October 26, 2021

Viewing posts 1–7 of 7

On the homepage and categories when I enter the "2 columns" and "first article in evidence" option, the last article excerpts shown is always odd, putting 10 articles visible.

If I enter 11 (from generale options) it always remains odd when I continue reading the various pages of the category or starting from the homepage. How to solve? Thanks!

Hi Atty,

Not sure I understand your question, do you mean when you choose 11 posts for the Blog pages show at most at settings > readings, the home page still show 10 articles most on each page?

If so, can you set to 11 so we can have a look?

Hi Atty,

Not sure I understand your question, do you mean when you choose 11 posts for the Blog pages show at most at settings > readings, the home page still show 10 articles most on each page?

If so, can you set it to 11 so we can have a look?

Hi Ying, I'm sorry, I didn't make myself clear.

--> layout --> blog --> 2 columns and featured image selected.

When you visit my homepage you can see 11 article summaries, including the one featured at the beginning. The same when you visit a category page.

Now, I have selected a maximum of 10 articles for the homepage and for the categories but, with the image of the article highlighted, they become 11.

How can I go about solving this problem? If I change the homepage / categories to 11 articles they have an even number, but if I continue on the next page, their number becomes odd, because there is not the first large image you find at the beginning (article-image in the foreground ).

I hope I explained myself. Thank you!

Ah I see what you mean, that makes sense :)

Give this PHP snippet a try to set 11 posts for the 1st page, you can set it to 10 for the other pages at settings > reading.

add_action( 'pre_get_posts', 'tu_change_posts_per_page', 1 );
function tu_change_posts_per_page( &$query ) {
    if ( ! is_main_query() ) {
        return;
    }

    if ( ! $query->is_paged ) {
        $query->set( 'posts_per_page', 11 ); // First page 11 posts
    }
}

Adding PHP: https://docs.generatepress.com/article/adding-php/

Hi Ying, it works perfectly. Thank you very much! :)

Glad to hear that :)

This archived topic is closed to new replies.