Site logo

Archived topic

Ad Placement / Custom Hook Code

9 replies · Started by Steph on March 26, 2022

Viewing posts 1–10 of 10

Hey,

I just join an ad network (SheMedia) and now have to place the ads. I already added some, but I would love to place some inside of my posts.

I assume I have to use a 'generate_inside_container' hook but is there a where to specify where and how often ads are placed?

If possible, I want a maximum of 4 ads per post and only before every second H2 starting with the second one. And then add a little bit of space between the ad and the H2 (around 25 px?).

Hey Ying,

thank you. That sure could work if there is a way to adjust the code a bit.

Do you know how I would have to alter that code if I want to create new hooks just before certain H2 headings?

I'd obviously have to create several new hooks (3 or 4) for the different locations, but after that, it should be rather straightforward, right?

You can try play around with the code, change where the </p> is to </h2>.

Adjusting the code only that way does not work. Especially as I want it after different headings... wouldn't that mean I'd also have to specify where?

Hi there,

for that kind of control you will want to use the Ad Inserter plugin:

https://en-gb.wordpress.org/plugins/ad-inserter/

It has all the various content filter functions built in - so placing ads where you want is a breeze. The Free versions should suffice.

Hey David,

I tried that plugin after reading about it in one of the other threads, but it does not have a feature to add ads before headings... I under no circumstances want ads within texts, hence the focus on placing them before headings. Am I missing something?

I might be wrecking my brain with this quest of mine o.O'

Omg. Thank you so much!

You are amazing.
Switching to GeneratePress really was the best decision.

Awesome - glad to be of help!

This archived topic is closed to new replies.