有沒有更好的方式在wordpress中獲取自定義帖子類型的類別名稱?wordpress,獲取自定義帖子類型的類別名稱
<?php // get the portfolio categories
$terms = get_the_terms($post->ID, 'filters');
if ($terms && ! is_wp_error($terms)) :
$names = array();
$slugs = array();
foreach ($terms as $term) {
$names[] = $term->name;
$slugs[] = $term->slug;
}
$name_list = join("/", $names);
$slug_list = join(" category-", $slugs);
endif;
?>
<!-- BEGIN portfolio-item-->
<li class="portfolio-item third column category-<?php echo $slug_list; ?>" data-filter="category-<?php echo $slug_list; ?>">
感謝您的幫助;非常感激 –