Site logo

Archived topic

Is adding content inside the loop working in the GP 3.0 update?

3 replies · Started by Eric on October 14, 2020

Viewing posts 1–4 of 4

Hey GP Team, I read here (https://generatepress.com/forums/topic/how-to-place-adsense-ad-unit-without-any-3rd-party-plugin/) that adding content inside the loop was possibly included in the next GP update? I just wanted to confirm if we can now add hook elements inside the content loop? Like adding the hook after counting 5 paragraph tags, or counting 3 list tags and adding the hook there (Ad Inserter functionality)? Has this been added to GP 3.0 and if so, how can we trigger this exactly? Thanks for your time and more power GP Team!

Hi there,

GP 3.0 introduced the generate_do_template_part() function.
It can be used in a variety of ways, such as replacing the loop content template.

It also has its own hooks, heres an example of that for adding content within the archive loop ( eg. insert content after X posts ):

https://docs.generatepress.com/article/generate_after_do_template_part/

However, what it does not do is filter the_content() which is what you require if you wanted to insert content after X paragraphs. Heres an example of that:

https://generatepress.com/forums/topic/insert-html-element-above-first-h2-in-single-posts/#post-873244

Hi again David! OK copy that... :) thanks!

You're welcome

This archived topic is closed to new replies.