Archived topic
Custom Hook element
3 replies · Started by Den on January 5, 2022
Hi team,
Actually, I want to know if there is a way where I can display the hook as per my choice.
For example: I want to show the hook element after Paragraph 2
Is it possible? If yes, then how?
Hi there,
Action Hooks don't exist inside the post content. As hooks have to be 'baked' into the template code.
However you can create a Shortcode to output a Hook and in turn filter the_content to insert that shortcode.
Very convuluted - and Ying provides the code for that here:
https://generatepress.com/forums/topic/show-element-after-specific-paragraph/#post-2067989
With that code added it will insert a hook after the 2nd paragraph of all posts.
And in a GP Hook element you can select the Custom Hook and add: after_first_paragraph to the custom hook field.
Thanks David. You guys are doing an amazing job.
Have a good day.
Glad to be of help