I’ve a state of affairs the place I have to show classes on the Archive Web page of CPTs, but when the class just isn’t used wherever within the CPT, it must be excluded from the checklist.
For instance, I’ve a CPT for “Books” and “Motion pictures”. I created a submit contained in the Books CPT and connected it to the “Horror” class. I additionally created one other submit within the “Books” CPT and eliminated all of the classes from it.
Now, after I add the under code to the archive web page, it’s going to present the “Horror” class within the “Books” Archive web page in addition to on the “Motion pictures” Archive web page.
<?PHP
$classes = get_categories(
array(
'orderby' => 'identify',
'order' => 'ASC'
)
);
foreach ($classes as $class) {
echo '<li class="filter-tab-list archive__filterizr-btn" data-filter="' . $category->term_id . '"> ' . $category->identify . ' </li>';
}
?>
Is there any method I can exclude the empty class from the “Motion pictures” archive web page?
Thanks upfront 🙂