Support

Account

Forum Replies Created

  • Thanks to ACF support’s help, this has been solved!

    
    acf_setup_meta( $block['attrs']['data'], acf_get_block_id( $block['attrs']['data'] ), true );
    get_field( 'filter_categories' );
    

    The true in the call to acf_setup_meta() means it’s replacing the main meta data, which you might not want to do if you still need to access it. You can do it this way to preserve it:

    
    $block_id = acf_get_block_id( $block['attrs']['data'] );
    acf_setup_meta( $block['attrs']['data'], $block_id );
    get_field( 'filter_categories', $block_id );
    
  • @hube2 Here’s what the block’s data looks like from parse_blocks():

    Array (
       [blockName] => site/recipes
       [attrs]     => Array (
          [name] => site/recipes
          [data] => Array (
             [heading_level]                                   => h2
             [_heading_level]                                  => blocks-recipes-heading_level
             [items_per_page]                                  => 9
             [_items_per_page]                                 => blocks-recipes-items_per_page
             [show_pagination]                                 => 1
             [_show_pagination]                                => blocks-recipes-show_pagination
             [filter_categories_0_category]                    => easy_meal_categories
             [_filter_categories_0_category]                   => blocks-recipes-filter_categories-category
             [filter_categories_0_easy_meal_categories-value]  => 30-minutes-or-less
             [_filter_categories_0_easy_meal_categories-value] => blocks-recipes-filter_categories-easy_meal_categories-value
             [filter_categories_1_category]                    => consumer_symbols
             [_filter_categories_1_category]                   => blocks-recipes-filter_categories-category
             [filter_categories_1_consumer_symbols-value]      => dairy-free
             [_filter_categories_1_consumer_symbols-value]     => blocks-recipes-filter_categories-consumer_symbols-value
             [filter_categories]                               => 2
             [_filter_categories]                              => blocks-recipes-filter_categories
          )
          [mode] => preview
       )
       [innerBlocks]  => Array ()
       [innerHTML]    => EMPTY STRING
       [innerContent] => Array ()
    )
    

    filter_categories is a repeater containing a dropdown to select the category and another dropdown to select the value. Each category has its own set of values so there’s a conditional on each value dropdown to match the selected category. That’s why for the value the category name is a part of the key filter_categories_0_<category>-value. In the above code, there are 2 filters selected, easy_meal_categories = 30-minutes-or-less and consumer_symbols = dairy-free.

    I realize I could do this the hard way and parse the keys out, but that’s brittle and especially difficult if repeaters are nested.

  • @johnnycomelately I put in a support ticket for this back then and got a reply that it’s a known issue and they’re currently working on it. They estimated a beta for it in January. Haven’t heard anything since then.

  • I’m also looking for a solution to this as I’ve created blocks that are only meant for use in the Header & Footer widget areas and want to restrict their use to only those. Unfortunately putting them into the widgets category doesn’t restrict them to at least the widgets page, it just puts them in that category.

    Looking forward to this being available.

Viewing 5 posts - 1 through 5 (of 5 total)