php – Exclude a category ID from the following function

Question

I’ve used a query that will query if the post in a specific category, to show a list of subcategories it belongs to.

The problem I’m having is I also want to exclude a specific subcategory from the output.

The current code is:

<?php
                    foreach((get_the_category()) as $childcat) {
                    if (cat_is_ancestor_of(81, $childcat)) {
                    echo '<li><a href="'.get_category_link($childcat->cat_ID).'">';
                     echo $childcat->cat_name . '</a></li> ';
                    }}
                ?>

Is there something I can add to this to exclude a category ID as well?

0
Emma 1 month 2023-05-04T07:05:16-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse