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;
}
?>
此代碼告訴我所有來自「產品」的術語,但我只想從「產品」中包含「良好」一詞的術語。