-
Bernardo
Hi,
We are changing from Oxygen to Generatepress, so now we are in the learning phase about GP.
There, in Oxygen, we use to have several blocks we call “templates”: header, footer, cta blocks, buttons, whatever.
When we change a link of the button, for example, we change only in the template and then all these buttons in the entire site changes too.
I’m not talking about styling only. I’m talking about button as a block, a pattern.
I can’t find a way to make it happen with GP.
Could you help me, please?
-
Alvind
Hi there,
In GeneratePress, we have a similar feature called Elements. This module allows you to create templates for various parts of your website like footer, sidebar etc, and display them via any hooks throughout the theme.
Here’s a few resources on the Elements module:
https://generatepress.com/introducing-the-gp-theme-builder/
https://docs.generatepress.com/collection/elements/ -
Bernardo
Right. I was trying to use the “Elemnts” feature, but can’t do it for a button.
Could you please describe the steps?
What I did is:
Create a Block > Type “Hook” > “Custom Hook” > Custom hook name “btn-lg”
As you can see here: https://prnt.sc/dLbmcaUw-tdp
What am I missing?
-
David
Hi there,
thats not the way GP Elements work.
The block element ( and hook element ) uses WordPress hooks, which are found in many places in WordPress coed, and in this instance in the GP Themes templates. See here for an example:
That is the single post template and before and after the content we add hooks:
before_main_content
andafter_main_content
.And the theme is riddled with hooks, for the main ones you can see here:
https://docs.generatepress.com/article/hooks-visual-guide/
Likewise some plugins have front end hooks that content can be injected into.
And these hooks are for inserting content into that place.
But buttons are plain HTML in your content, so unless you use some kinda of shortcode to add a button they won’t have any hooks within them.
If you want a Button that you can a) add to many places and b) be updated altogether by changing one button then you would use a WordPress Synced Pattern:
https://wordpress.org/documentation/article/reusable-blocks/
-
Bernardo
Oh, now I got it.
Thank you very much.
-
David
You’re welcome
-
Bernardo
Hello again. It seems the “Pattern” isn’t working. May I missing something?
1 – The local pattern was created (it’s a button) – https://prnt.sc/vxtOSTfPXgLQ
2 – It’s really sinchronized only in the original page it was created
3 – When I try to put the same pattern in other pages, it isn’t “synching” as it should be – https://prnt.sc/LyjxQNsAXZpCI’m using the “local patterns” – https://prnt.sc/y6-f9kEf-UpD
Any help, please?
-
Odd, its not something the Theme controls, as its a core function of WordPress.
What happens if you insert the pattern from the Block Inserter? -
Bernardo
That’s it!!!
You’re the best, man.
-
Glad to be of help.
- You must be logged in to reply to this topic.