[Resolved] Using HOOK from Custom WP Block ??

Home Forums Support Using HOOK from Custom WP Block ??

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #943938
    Sebastien

    Hi,

    At the moment, I use a GP ELEMENT > Header to add custom content into the header of a page.
    I plan to build a php template to get more flexibility.

    1) Can you tell me which is the right php Filter/Hook to replace this element?

    2) In a second time, I would like to apply this hook to a WP Custom Block (that I’ve made). I would like to know if my idea would work?
    The plan is to apply the hook to the BLOCK: That would able me to manage my “header content” from the Nativ WP Editing page.
    I’m not sure if this method will have any effect with performence (maybe block get more time to load?)

    Thanks.

    #944128
    Leo
    Staff
    Customer Support

    Hi there,

    1. That depends on where the code is supposed to be added. Usually it should be in wp_head in Hooks Elements:
    https://docs.generatepress.com/article/hooks-element-overview/

    2. Not sure if I fully understand. You are referring to Gutenberg blocks? It’s not possible use Gutenberg editor with Elements currently unfortunately.

    Let me know if this helps 🙂

    #944164
    Sebastien

    Hi,

    Thanks for the answer.

    about the 2cnd point:

    I’ve already built my own custom WP Gutenber Block.
    What I want is that this block appears into my Header.
    Can I use:

    wp_head( 'your_hook_name','example_function_name' );  
    function example_function_name() { ?> 
        Insert your hook contents in here.
    <?php }

    hook into my Custom Gutenberg Block (into the .php template) to “force” it to be displayed into the Header (the same way like using Hooks Element) when it is called?
    The plan is to add this custom block into a page. Then when the page is loaded (when the block is called) it is displayed into the header (instead of the normal content position).

    How can I manage that? Where do I need to place the hook? thanks

    #944165
    Leo
    Staff
    Customer Support

    It’s not possible to insert a block into hook unfortunately.

    You will have to build the content directly in hooks without blocks.

    #944390
    Sebastien

    Thanks Leo for information,

    My question may be a bit redudent but you said it is not possible to insert a block into hook.
    But is it possible to insert hook into blook?

    The block would be called… and from inside its template it would launch the hook to force its position to be into the header.

    #944397
    Leo
    Staff
    Customer Support

    Don’t think that’s possible either.

    What exactly are you trying to build? Couldn’t you just build it with default hooks and HTML content?

    #944400
    Sebastien

    I try to use a block that I could manage (editing content) directly from the EDITING PAGE (gutenberg, like a classic Block) AND I would this block be positionned into the header (like it does when using Hook Element or php hook + HTML content..

    Of course I can stay with a “hook element” and html….. but for my end users and for I, it would be definitly nicer to regroup all the content into the same Editing page.

    it would be very helpfull if you can confirm that is not currently possible ?

    thanks so much !

    #944539
    Leo
    Staff
    Customer Support

    Yes I can confirm this is not possible.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.