Site logo

[Support request] Cumulative Layout Shift (Issue)

Home Forums Support [Support request] Cumulative Layout Shift (Issue)

Home Forums Support Cumulative Layout Shift (Issue)

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #2477205
    Anil kumar

    When I have placed ads below the entry title, then I am facing the problem of Cumulative Layout Shift.

    Image link

    website link

    #2477208
    Leo
    Staff
    Customer Support

    Hi there,

    From my understanding, ads often cause CLS issues and it’s not something the theme can control.

    We could try to reserve the space for ads with CSS, but then users who use a browser app like AdBlock will see a big empty space.

    #2477216
    Anil kumar

    please provide any css code for reserve the space for ads.

    #2477227
    Leo
    Staff
    Customer Support
    #2477243
    Anil kumar

    I have pasted the code in css but how to paste html code and where. because i am using ad-inserter.

    #2477246
    Leo
    Staff
    Customer Support

    because i am using ad-inserter.

    In that case, you would need to check with Ad Inserter’s support team.

    #2477250
    Anil kumar

    no other suggestions?

    #2477638
    Anil kumar

    Hello David, please tell me what to do. please provide any css code for reserve the space for ads.

    #2477644
    Fernando
    Customer Support

    Hi Anil,

    With David’s approach, you’ll need to add your advertisement code through a Hook Element. Reference: https://docs.generatepress.com/article/hooks-element-overview/

    #2477671
    Anil kumar

    Thanks Fernando, problem solved. but I want to show this ads only mobile version. please help.

    #2477674
    Fernando
    Customer Support

    Can you change the Hook Element code to this?:

    <?php
    
    if(wp_is_mobile()) { ?>
    <div class="header-advert-wrap">
    // Your Ad script goes here
    </div>
    
    <?php } ?>

    Make sure to add your ad script.

    Make sure to check “Enable PHP” in the Hook Element settings as well.

    #2478593
    Anil kumar

    After entering the code, the ad is not visible in the desktop but the desktop space is still being created in Core Vital. Because of which Largest Contentful Paint issue is coming.

    photo (Largest Contentful Paint)

    #2478750
    David
    Staff
    Customer Support

    Referring to my CSS here:

    https://generatepress.com/forums/topic/reserve-space-for-ads-in-header-or-post/#post-1855257

    You only need the second rule ie.

    @media(max-width: 768px) {
        .header-advert-wrap {
            min-height: 200px;
        }  
    }

    Adjust the min-height to suit your advert.

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