Archived topic
Ad Banner after all X-Posts on category pages
11 replies · Started by Karsten M. e.K. on August 31, 2021
Hi there,
I want to add some banner ads on my category pages on witze.tv, on pages like this:
https://www.witze.tv/lustige-witze/fritzchen-witze/
I created a hook, which I adapted from a user here in the forum:
<?php global $loop_counter;
$loop_counter++;
// show ad every 4th post
if ( $loop_counter % 4 == 0 ): ?>
<!-- ad code here -->
***<div id="ezoic-pub-ad-placeholder-600"> </div>
<br />
<?php endif; ?>
Now I can't find the right hook for that, because I want the banner to stand alone, like:
Post Post Post
Banner
Post Post Post
Banner
...
Is that possible? The banners should stay alone and should not be part of the container Post boxes...
Thank you very much!
Best regards
Michael
Hi there,
does you code work ie. it injects the advert in the correct part of the loop?
If so it just needs some CSS to force its width to 100%. If you want to enable the code, i can see what HTML it is generating and provide the CSS for that.
Hi David,
good idea, I activated the script and it seems, it does its job. In the moment there are now banners to see, I think it is, because, ezoic decides by itself, if they show an ad or not.
You can see each potential banner ad marked with ***

I use the hook: generate_after_content
Thanks and best regards
Michael
Can you change the Hook to a Custom Hook, and add: generate_after_do_template_part
That works better, but I need the banner in a separate row, like:
Row1: Post Post Post
Row2: Banner
Row3: Post Post Post
Row4: Banner
On mobile, it looks good, but not on desktop, if it is not possible for desktop, I can live with the solution :)
Yeah, mobile is the future, I am fine with that, thank you so much!!!
Looks like it just needs the left padding added to align it - try this CSS:
@media(min-width: 769px) {
.generate-columns-container .ezoic-ad {
padding-left: 20px;
}
}
that looks not so bad, see screen:

Any idea, how I can adjust it to the center on desktop?
Great support!
Thanks
Hmmm... thats a problem with dynamic adverts, they're all different sizes.
Try this CSS it should force the ad to be centred.
.generate-columns-container {
justify-content: center;
}
Works fine for me, thank you so much!
Glad to be of help!