[Support request] Custom hooks

Home Forums Support [Support request] Custom hooks

Home Forums Support Custom hooks

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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.

    #870451
    David
    Staff
    Customer Support

    Hi 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.

    #870734
    Vl

    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.

    #870748
    David
    Staff
    Customer Support

    Unfortunately 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

    #871314
    Vl

    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”?

    #871616
    David
    Staff
    Customer Support

    Hooks 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.

    #871672
    Vl

    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?

    #871719
    David
    Staff
    Customer Support

    Thats correct. Currently you would have to select the child pages in the display rules as well.

    #871720
    Vl

    Thank you.

    #871767
    David
    Staff
    Customer Support

    Glad to be of help

    #1657289
    David

    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!

    #1657429
    Leo
    Staff
    Customer Support

    Hi David,

    Please open a new topic and link us to the page in question.

    Thanks!

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Custom hooks’ is closed to new replies.