If in_category function for Custom Taxonomies
-
Hi everyone, this topic might seem easy and probably has a simple answer, but for the life of me I can’t get it to work. I used to use to use if ( in_category functions to display different location data. Recently, we have had so many categories, I thought it would be easy to replace them with custom taxonomies to be more organized.
I think I have tried everything I came across and I’m not sure what I’m doing wrong. I’m using the plugin “CPT UI” to create the taxonamies, but helpful links like:
https://developer.www.ads-software.com/reference/functions/is_object_in_term/
https://developer.www.ads-software.com/reference/functions/has_term/
https://developer.www.ads-software.com/reference/functions/is_tax/
and many others are not working.This is what the code looked like before
<?php if ( in_category( 'Church' )) { ?> • <a href="https://abandonedar.com/class/church/">School</a> <?php } ?>
or
<?php if ( in_category( 'hotel-motel' )) { ?> • <a href="https://abandonedar.com/class/church/">Hotel/Motel</a> <?php } ?>
And these are a few I tried:
<?php if ( is_tax( 'class', $church_class ); { ?> • <a href="https://abandonedar.com/type/church/">Church</a> <?php } ?>
<?php has_term( $hotelmotel = '', $class = '', $post = null ); { ?> • <a href="https://abandonedar.com/type/church/">Hotel/Motel</a> <?php } ?>
<?php has_term( $hotelmotel = '', $class = '', $post = null ); { ?> • <a href="https://abandonedar.com/type/church/">Hotel/Motel</a> <?php } ?>
So the main issue is that it is only half working. Most of these function will print all functions in “Class” instead of just the ones selected. Any clues as to what I’m doing wrong?
Thanks in advance!
The page I need help with: [log in to see the link]
- The topic ‘If in_category function for Custom Taxonomies’ is closed to new replies.