-
andytlaird
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?
-
David
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 themy-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.
-
andytlaird
Thank you David – awesome support. I think I’ll wait for the GenerateBlocks Pro 1.7 update.
-
David
You’re welcome
- You must be logged in to reply to this topic.