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.

Generateblocks partly synced pattern

  • Hi,

    Is it possible for a part of a synced pattern to not be synced?

    I have a button with dynamic data that references an AFC called price_tear_trough.
    I want to change that dynamic data freely while still keeping it a synced pattern.

    Example: on the page /tear-trough/, i want to reference price_tear_trough
    On /smootheye/, I want to be able to change the reference freely to something else, such as price_smootheye

    Is this possible or are there perhaps another approach to this?
    The issue is otherwise i have to create one local pattern per page, instead of having only one local pattern

  • Hi there,

    partially synced patterns isn’t a thing yet.. WordPress are working on that , although i am not 100% it would handle this requirement.

    So you would need to do something to workaround that.

    For example:

    1. add a Custom Field to the page to store the “slug” eg. tear_trough or smootheye
    2. add a GB Headline block and
    2.1 set its Dynamic Data to display that custom field so it actually shows that value on the front end.
    2.2 give it an Advanced > Additional CSS Class of: dynamic-meta

    3. Now a PHP Snippet:

    
    add_filter( 'render_block_generateblocks/container', function( $block_content, $block ) {
        if ( 
          !is_admin() && 
          ! empty( $block['attrs']['className'] ) && 
          strpos( $block['attrs']['className'], 'dynamic-meta' ) !== false 
        ) {
            $meta_field_name = 'price_' . $block_content;
            $meta_field_value = get_field( $meta_field_name , get_the_ID());
            if ( $custom_field  ) {
                $block_content = $meta_field_value;
            }
        }
      
        return $block_content;
     }, 10, 2 );
    

    This should use the dynamic data in the headlibe block to build a new get_field request to return the value you need.

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