- This topic has 11 replies, 2 voices, and was last updated 5 years, 1 month ago by
Leo.
-
AuthorPosts
-
April 16, 2019 at 6:46 am #870436
Vl
Hi!
I need to add a hook to a specific place on the page. I tried to do this with a Custom hook, but I can not understand what I have to write in the line: “Custom Hook Name”?
How to put a custom hook on a specific place on the page?
Thanks.April 16, 2019 at 6:48 am #870451David
StaffCustomer SupportHi there,
Hooks have a specific place in a Template you can see the majority of them in these visual guides:
https://docs.generatepress.com/article/hooks-visual-guide/
Custom Hook fields are used for hooks that aren’t listed or those that are within another plugin.
April 16, 2019 at 9:20 am #870734Vl
Thanks for the answer.
Can I attach a hook to an ID or class?
This is necessary in order to insert a hook anywhere on the page, for example, inside an article.April 16, 2019 at 9:28 am #870748David
StaffCustomer SupportUnfortunately not – that would be pretty cool 🙂
What you can do is filter the_content(). Example here was used to add the featured image after the 2nd paragraph:
https://generatepress.com/forums/topic/featured-image-inside-the-article/#post-708308
April 17, 2019 at 3:43 am #871314Vl
Thanks for the answer.
I have another question not about Custom hooks.
For example, the site has the following structure:
http://www.site.com/page1/page2/page3/
Is it possible to insert a hook on the “page1” so that it is automatically inserted on the “page2” and “page3”?April 17, 2019 at 7:10 am #871616David
StaffCustomer SupportHooks are a part of the Post Template. So if you add content to a Hook and set that to display on All Pages for example then that content would appear on all Pages including paginated ones.
April 17, 2019 at 8:15 am #871672Vl
That is, I can add a hook only to all pages or to individual pages that I choose in the settings.
And I cannot add a hook to the parent page so that it is automatically added to all child pages.
This is true?April 17, 2019 at 8:57 am #871719David
StaffCustomer SupportThats correct. Currently you would have to select the child pages in the display rules as well.
April 17, 2019 at 8:58 am #871720Vl
Thank you.
April 17, 2019 at 9:30 am #871767David
StaffCustomer SupportGlad to be of help
February 13, 2021 at 1:14 pm #1657289David
Hi there
I want to add a custom hook to my posts above a custom block that is at the bottom of each post. I have tried adding codes from the custom block and others from inspecting the items on the page.
Am I adding the wrong code or is it not possible to create a hook anywhere?
I was trying all sorts with ‘generate_before…’
(I did install Code Snippets plugin, but didn’t know where to start)
Thanks for all your tutorials and replies – GP Rocks!
February 13, 2021 at 7:47 pm #1657429Leo
StaffCustomer SupportHi David,
Please open a new topic and link us to the page in question.
Thanks!
-
AuthorPosts
- The topic ‘Custom hooks’ is closed to new replies.