[ad_1]
Hi @adrian2k7, This block does not support term meta field by default, but you can add custom code to make it work with it or any kind of meta fields. Please refer to the plugin description for more details. Here is the sample code I copy from the plugin description:
// Create a function to build the value for the field. function yourprefix_get_attr_value( $term_id ) { $cat_attr_value = get_term_meta( $term_id, 'cat_attr', true ); // If the meta field is an ACF Field. The code will be: // $cat_attr_value = get_field( 'cat_attr', 'term_' . $term_id ); return $cat_attr_value; } // Render the block on the front end. add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id ) { $field_name = $attributes['fieldName'] ?? ''; // Replaceunique_name_for_cat_attrwith your unique name. if ( 'unique_name_for_cat_attr' === $field_name && is_tax( 'product_cat' ) ) { $term_id = get_queried_object_id(); $block_content = yourprefix_get_attr_value( $term_id ); } return $block_content; }, 10, 4);
Thread Starter
Adrian
(@adrian2k7)
Hello Phi,
Thank you.
Then this is a feature request, would be much easier to not write custom code 😉
Adrian
Thank you @adrian2k7 for your suggestion. It has been on my todo list for a future version.
Regards,
Phi
