Hi Marumoro,
To achieve such, you can try adding this PHP snippet:
add_filter( 'generate_dynamic_element_text_output', function( $term_output, $block ){
if ( 'terms' === $block['attrs']['gpDynamicTextType'] && 'd68a6ef2' === $block['attrs']['uniqueId']) {
$terms = get_the_terms( get_the_id(), $block['attrs']['gpDynamicTextTaxonomy'] );
if ( is_wp_error( $terms ) ) {
return $block_content;
}
$term_items = array();
foreach ( (array) $terms as $term ) {
var_dump(substr_count(get_category_parents($term->term_id),"/"));
if(substr_count(get_category_parents($term->term_id),"/")>=2) {
if ( ! isset( $term->name ) ) {
continue;
}
$term_items[] = sprintf(
'<span class="post-term-item term-%2$s">%1$s</span>',
$term->name,
$term->slug
);
}
}
if ( empty( $term_items ) ) {
return '';
}
$sep = isset( $block['attrs']['gpDynamicTextTaxonomySeparator'] ) ? $block['attrs']['gpDynamicTextTaxonomySeparator'] : ', ';
$term_output = implode( $sep, $term_items );
if ( ! empty( $block['attrs']['gpDynamicTextBefore'] ) ) {
$term_output = $block['attrs']['gpDynamicTextBefore'] . $term_output;
}
}
return $term_output;
},15,2);
Kindly replace d68a6ef2
with the unique ID of your Dynamic Headline Block.
How to get the unique ID: https://share.getcloudapp.com/z8uLkDEz
Hope this helps.