- This topic has 12 replies, 4 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
December 29, 2022 at 10:47 am #2477205
Anil kumar
When I have placed ads below the entry title, then I am facing the problem of Cumulative Layout Shift.
December 29, 2022 at 10:50 am #2477208Leo
StaffCustomer SupportHi 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.
December 29, 2022 at 10:55 am #2477216Anil kumar
please provide any css code for reserve the space for ads.
December 29, 2022 at 11:03 am #2477227Leo
StaffCustomer SupportTake a look at David’ suggestion here:
https://generatepress.com/forums/topic/reserve-space-for-ads-in-header-or-post/#post-1855257December 29, 2022 at 11:20 am #2477243Anil kumar
I have pasted the code in css but how to paste html code and where. because i am using ad-inserter.
December 29, 2022 at 11:26 am #2477246Leo
StaffCustomer Supportbecause i am using ad-inserter.
In that case, you would need to check with Ad Inserter’s support team.
December 29, 2022 at 11:36 am #2477250Anil kumar
no other suggestions?
December 30, 2022 at 12:32 am #2477638Anil kumar
Hello David, please tell me what to do. please provide any css code for reserve the space for ads.
December 30, 2022 at 12:38 am #2477644Fernando 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/
December 30, 2022 at 1:42 am #2477671Anil kumar
Thanks Fernando, problem solved. but I want to show this ads only mobile version. please help.
December 30, 2022 at 1:51 am #2477674Fernando 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.
December 30, 2022 at 11:30 pm #2478593Anil 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.
December 31, 2022 at 5:18 am #2478750David
StaffCustomer SupportReferring 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-heightto suit your advert. -
AuthorPosts
- You must be logged in to reply to this topic.