最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to filter wp_list_categories output with some custom post type meta query?

programmeradmin1浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论