1

The main point, why i want to do this,

..is to be able to filter these term listings conditionally, such as: if the CPT that is connected with this taxonomy has some meta fields that are empty or have default value in them, we need those CPT-s to be hidden in the term lists.

I wonder, is it possible to achieve this other than building a custom Query with tax_query and meta_query (+ all the custom html output logic, etc.) for it to 'mimic' what i would try to do as written in this question's title?

Important: i need it to work not only on the taxonomy archive pages, but as secondary queries as well. (e.g. widgets, shortcodes)

in other words, how can i make this filtered somehow.. by specific CPT's custom meta values?

function hungarian_locations_tag_cloud(){
        $args = array(
        'echo'         => false,
        'taxonomy'     => 'locations',
        'orderby'      => 'name',
        'show_count'   => false,
        'pad_counts'   => false,
        'hide_empty'   => false,
        'hierarchical' => true,
        'depth'        => '1',
        'title_li'     => '',
        'child_of'     => '11' // Hungary
        );
    $lista = '<ul class="location-tags hungary">';
    $lista .= wp_list_categories( $args );
    $lista .= '</ul>';

    return $list;
}
add_shortcode( 'hungarian_locations', 'hungarian_locations_tag_cloud' );

I just would love to save some dev time + keep the code simple, if there is any smart solution on this. Cheers!

2
  • It really helps if you switch your habit and start naming and commenting in English. The main reason is, that you can copy/paste share it on site like this one and context will be clear without changing a single line.
    – kaiser
    Dec 8, 2020 at 22:11
  • 1
    @kaiser ok, done. Tho, there was not much non-english words and they were non-relevant or necessary information for finding a solution to this problem. ;) Dec 8, 2020 at 22:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.