【发布时间】:2021-01-20 07:40:41
【问题描述】:
使用简码[tagsListfoot],我在网站的地下室显示了一堆地标。现在看起来像这样:
add_shortcode( 'tagsListfoot', 'getTagListfoot' );
function getTagListfoot() {
global $post;
$args = array(
'taxonomy' => 'tags_type',
'order' => 'RAND',
'number' => '10',
);
wp_tag_cloud( $args );
}
每个标签都有一个自定义字段(2 个单选 - “是”和“否”)。是否可以将自定义字段中的值添加到云参数?理想情况下,您应该只输出值为“yes”的标签。
我尝试了类似的方法,但它没有帮助(
add_shortcode( 'tagsListfoot', 'getTagListfoot' );
function getTagListfoot() {
global $post;
$tag_footer = ( 'yes' == get_term_meta( $tag->term_id, 'pokazat-v-podvale' ) );
$args = array(
'taxonomy' => 'tags_type',
'order' => 'RAND',
'number' => '10',
'include' => $tag_footer,
);
wp_tag_cloud( $args );
}
【问题讨论】:
-
向您的参数添加自定义字段查询。 developer.wordpress.org/reference/classes/wp_query/…