0
我想通过单词获取现有术语。WordPress通过单词获取分类术语
例如:将显示包含单词“good”的所有关于“产品”的术语。
所以我们得到:好书,好电影,好玩具等
看看这段代码:
<?php
$args = array('hide_empty=0');
$terms = get_terms('products', $args);
if (! empty($terms) && ! is_wp_error($terms)) {
$count = count($terms);
$i = 0;
$term_list = '<p class="my_term-archive">';
foreach ($terms as $term) {
$i++;
\t $term_list .= '<a href="' . get_term_link($term) . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a>';
\t if ($count != $i) {
$term_list .= ' · ';
}
else {
$term_list .= '</p>';
}
}
echo $term_list;
}
?>
此代码告诉我所有来自“产品”的术语,但我只想从“产品”中包含“良好”一词的术语。