[Resolved] Featured post using block element on paginated pages in blog

Home Forums Support [Resolved] Featured post using block element on paginated pages in blog

Home Forums Support Featured post using block element on paginated pages in blog

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1993986
    Alan Gautham

    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.

    #1994030
    David
    Staff
    Customer Support

    Hi there,

    might be easiest to treat it with some CSS:

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

    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.

    #1994147
    Ying
    Staff
    Customer Support

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

    Let me know πŸ™‚

    #1994423
    Alan Gautham

    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.

    #1995239
    Tom
    Lead Developer
    Lead Developer

    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!

    #1995470
    Alan Gautham

    Hi Tom,

    Awesome man. The snippet worked as expected. Thanks a lot for this outstanding support πŸ™‚

    #1996644
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.