- This topic has 9 replies, 3 voices, and was last updated 2 years ago by David.
-
AuthorPosts
-
March 26, 2022 at 9:34 am #2168189Steph
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?).
March 26, 2022 at 11:04 am #2168237YingStaffCustomer SupportHi Steph,
GP doesn’t have any hooks in the post content Unfortuanly.
So you would need to manually add the ads to your post content, or you can give this solution a try to create a custom hook after 1st paragraph:
https://generatepress.com/forums/topic/element-after-first-paragraph/#post-1937353Or you can try find some plugins which automatically place ads for you.
March 26, 2022 at 11:40 am #2168272StephHey 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?
March 26, 2022 at 3:03 pm #2168369YingStaffCustomer SupportYou can try play around with the code, change where the
</p>
is to</h2>
.March 28, 2022 at 4:48 am #2169605StephAdjusting 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?
March 28, 2022 at 5:09 am #2169635DavidStaffCustomer SupportHi 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.
March 28, 2022 at 5:19 am #2169645StephHey 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’
March 28, 2022 at 5:33 am #2169661DavidStaffCustomer SupportIf i understand correctly then you can do it with the Ad Insert plugin.
Its a little confusing but you can use the Paragraph Settingshttps://adinserter.pro/documentation/paragraph-settings
I was intrigued to see if it worked so did a quick test:
1. I checked Posts
2. I set Insertion:before paragraph
and then%2
which is every 2nd of.
3. Set the Paragraph with Tags toh2
And that worked 🙂
March 28, 2022 at 6:11 am #2169717StephOmg. Thank you so much!
You are amazing.
Switching to GeneratePress really was the best decision.March 28, 2022 at 6:12 am #2169718DavidStaffCustomer SupportAwesome – glad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.