Site logo

Archived topic

"Make first post featured" leads to uneven number of remaining posts

12 replies · Started by Florian on November 10, 2018

Viewing posts 1–13 of 13

Hello,
when I make my first post big with "Make first post featured", the remaining posts are shown in an uneven number. Wouldn't it make more sense to fill up all the remaining space?
Take a look at my front page to see an example.

Hi there,

Right now, the featured post counts towards the posts per page option set in "Settings > Reading".

To make things even when using a featured image, you'll want to increase that posts per page option by 1 :)

Thank you!

Unfortunately this breaks the 2nd page where there is no featured post.

Give this a shot:

add_action( 'pre_get_posts', function( $query ) {
    if ( ! function_exists( 'generate_blog_get_defaults' ) ) {
        return;
    }

    $settings = wp_parse_args(
        get_option( 'generate_blog_settings', array() ),
        generate_blog_get_defaults()
    );

    if ( ! is_admin() && $query->is_main_query() && $settings['featured_column'] && ! is_paged() ) {
        $query->set( 'posts_per_page', get_option( 'posts_per_page' ) + 1 );
    }
} );

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

Thank you, it works! I left a little tip earlier today on your donate page. I'm gonna do that from time to time for your great help!

Thanks so much! Really appreciate it :)

Dear Tom,

The code worked great for me!

To reach excellence I would like to ask you a second question about it:

The first post on the 2nd page of the blog is also shown as the last post on the first page.

Is there any way to make this post not repeat?

Thank you very much for the support!

Hmm, that doesn't sound right. I suppose you could try removing this part of the code: && ! is_paged()

Now it works perfect, thank you!!

You're welcome :)

Dear developers, the code has stopped working.

Has there been any change in the last update that affected this?

Thanks for the support!

Hi there,

No, that code should still work as always.

Has anything else changed on your site? Maybe try deactivating your plugins one by one to check for conflicts.

This archived topic is closed to new replies.