Like the blog? Get the book »

Posts tagged: categories

Archive page 1 of 1
How to Check if Post has Taxonomy Term

How to Check if Post has Taxonomy Term

Something I did not know about when working with Custom Post Types and Custom Taxonomies. Normally when checking if a regular WP Post belongs to a specific category, we can use the WordPress function in_category(). But that does not work with Custom Post Types. To check if a CPT belongs to a specific term in a Custom Taxonomy, use has_term() instead.

Include the Category ID via post_class

Include the Category ID via post_class

The default output for WordPress’ post_class template tag includes class names for just about every type of page view imaginable:

© 2009–2021 Digging Into WordPress Powered by WordPress Monzilla Media shapeSpace