excluding categories from get_the_category list
-
I’m working on some php to generate a list of links based on the categories of the current post. So far I have this, which works great for most cases:
<?php $categories = get_the_category(); ?> <nav> <?php foreach ($categories as $category):?> <a href="<?php echo 'https://www.nameoflinkedsite.com/' . $category->slug . '-tickets' ?>"> <?php echo $category->name . ' Tickets<br>' ?></a> <?php endforeach; ?> </nav>
My only problem: I need to exclude certain categories, and get_the_category() doesn’t support this. I’ve tried a couple of solutions suggested elsewhere on the support forum, but none play nicely with the rest of my code. Any ideas?
You can view the test page for this code here:
https://www.fieldofschemes.com/1901/06/16/11239/ad-test-page/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘excluding categories from get_the_category list’ is closed to new replies.