Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Same Button All Over The Site (as a template)

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

  • 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/

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

  • 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:

    https://github.com/tomusborne/generatepress/blob/f0227eb702ccfa8345e8b26967edcb9c24301253/single.php#L22-L39

    That is the single post template and before and after the content we add hooks: before_main_content and after_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/

  • Oh, now I got it.

    Thank you very much.

  • You’re welcome

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