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.

Elements vs Local Patterns

  • I’ve created a testimonial in advanced custom field and the block in ‘Elements’ However, sometimes I would like to add it to separate posts or pages in different locations. So what I did was add the block to Local Patterns and then I can insert it anywhere. However, unlike ‘Elements’ if I change the styling in local patterns it won’t show on the front end. If I create an element how can I use this in to show wherever I want in a post or page?

  • Hi there,

    see here:

    https://wordpress.org/news/2023/07/synced-patterns-the-evolution-of-reusable-blocks/

    That method is the core method of saving Patterns.
    GenerateBlocks Pro 1.7 update is going to move the GB Local Patterns to that method.

    Today you can use a core Local Pattern and choose the Sync option, which means changing one Synced pattern will update all instances across the entire site.

    Alternatively, you could create a Shortcode and Hook a Element into it:

    1. Add this PHP Snippet to the site:

    
    add_shortcode('portable_hook', function($atts){
    	ob_start();
            $atts = shortcode_atts( array(
                'hook_name' => 'no foo'
            ), $atts, 'portable_hook' );
    	    do_action($atts['hook_name']);
    	return ob_get_clean();
    });
    

    2. This provides a Shortcode you can add to your posts eg.

    [portable_hook hook_name="my-custom-hook"]

    This will add a action hook called my-custom-hook to that position.

    3. Add a GP Block Elements, set the Hook to Custom Hook and add the my-custom-hook name.

    4. Set the Display Rules to the Entire Site.

    Whatever you add now to this element will get output wherever the shortcode gets added.

  • Thank you David – awesome support. I think I’ll wait for the GenerateBlocks Pro 1.7 update.

  • You’re welcome

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