Site logo

Archived topic

Featured post using block element on paginated pages in blog

7 replies · Started by Alan Gautham on November 6, 2021

Viewing posts 1–8 of 8

Hi Guys...

It's a blog site: https://www.geekextreme.com/

Blog and Post Archive template designed using Block element.

There are 2 block elements. One for the featured post and another for the rest of the posts on the page.

All is good on the front page. But once v are moving to page2 using pagination. The featured post is not carrying over there.

For example, chk this one: https://www.geekextreme.com/page/2/

B'cos of ad units attached to the top and bottom of a featured post, I would like to have a featured post for every blog page i.e. page1,page2 etc.

Kindly assist. Thank You.

Hi there,

might be easiest to treat it with some CSS:

.paged .generate-columns-container article:first-child {
    width: 100%;
}

Hi David...

Thanks for your quick response as always.

I would have used that CSS if ad units are not there in the block element for the featured post.

Two ad units are attached to the top and bottom of a featured post block unit.

Please chk this Screenshot: https://ibb.co/37DFHsb

Kindly advise for this situation.

Have you tried the CSS yet? I don't see a conflict between the CSS and the ads block.

Let me know :)

The CSS will make the first post take full width but it WON'T bring the ad blocks to page2/page3 etc which is in block element...

I am using ad shortcodes in the block element which is applied to featured posts.

To explain to you better... I am adding that CSS now...pls take a look at these 2 pages...

https://www.geekextreme.com/

https://www.geekextreme.com/page/2/

Thank you.

Hi there,

We can tell the template to display on paged pages like this:

add_filter( 'generate_should_render_content_template', function( $display, $post_id ) {
    $loop_item_display = get_post_meta( $post_id, '_generate_post_loop_item_display', true );

    if ( 'is-first-post' === $loop_item_display ) {
        global $wp_query;

        if ( 0 === $wp_query->current_post && is_paged() ) {
            $display = true;
        }
    }

    return $display;
}, 10, 2 );

Hope this helps!

Hi Tom,

Awesome man. The snippet worked as expected. Thanks a lot for this outstanding support :-)

Glad I could help! :)

This archived topic is closed to new replies.