Archived topic
Block Hook makes Menu disapear
11 replies · Started by troyw on October 13, 2021
Hey guys,
I have added a Block Hook to add a row of 5 buttons to my Home Page Header. The only Hook I could find to add this was the Hook Name 'Header'. Problem is, this makes the Menu disappear? I've tried lots of Hook Names, but can't seem to find one that keeps the menu and allows me to position the buttons where I want them.
Another issue I am having is that I can't seem to force the buttons to be the same size. How do I make them all conform to one size, as they are now changing depending on the text length?
Thanks
Hi there,
Let's handle one issue at a time.
Selecting "Header" in the hook would replace the actual header of your site.
Where are you actually trying to add the buttons?
Hey Leo,
Yes, I am trying to add the buttons to the header. The header itself is a Header Element.
Hi there,
To clarify, are you trying to hook in a Block Element inside a Header element?
If that's the case then that's not possible w/o some workaround because there are no hook locations inside a Header Element. you'll have to create a hook location inside manually.
You can add it manually using a shortcode.
See the add_shortcode snippet in this reply - https://generatepress.com/forums/topic/hook-in-hook/#post-1636333
With this, you can create a hook location anywhere on the site, meaning you can hook a Block element or Hook element anywhere. ;) (in your case, add a shortcode inside the Header Elements code area)
Another issue I am having is that I can’t seem to force the buttons to be the same size. How do I make them all conform to one size, as they are now changing depending on the text length?
This can be done with CSS. Can you link us to a sample page?
Hey Elvin,
I will check out the add_shortcode link you sent.
The buttons are the ones I am trying to Hook over header on the Home Page. As you can see, they are all different widths.
Valves, Fittings, Hose, Filtration and Measurement
The link is in maintenance mode. can you provide us access to check?
The buttons are the ones I am trying to Hook over header on the Home Page. As you can see, they are all different widths.
by "over header" did you mean before the Header element? If that's the case then the shortcode won' be necessary. You only need to hook the buttons to generate_after_header and then set the priority value to 1 so it goes before the Header element (Header elements have priority of 5.)
Hey Elvin,
Sorry mate, read that 'add_shortcode snippet post' and it makes no sense whatsoever to me.
Firstly, does the code snippet go in the functions.php file?
As for the rest, I have no idea how that relates to my Block Hook?
Thanks
Check link now
Aha,
Yes, changing the Hook to after_header and the priority to [1] seems to have done it.
Thanks.
So to force those buttons to be the same size, what do I need to do?
Try this setting for all the buttons - https://share.getcloudapp.com/NQu7qwoD
Hey Elvin,
That's much better. I had to change the Right and left spacing to 10 instead of 20, but it seems much better than it was, thanks.
I can fine tune it now, so thanks for advice.
Have a great day.
No problem. Glad to be of any help. :D