Skip to content

Instantly share code, notes, and snippets.

@joemaller
Created March 12, 2020 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemaller/670183c30464775793bc63132fe6f29a to your computer and use it in GitHub Desktop.
Save joemaller/670183c30464775793bc63132fe6f29a to your computer and use it in GitHub Desktop.
A simple is_term() conditional function for WordPress

Even though individual Tags, Categories and Taxonomies are all represented as WP_Term objects, WordPress has three separate conditional tags for sorting them out: is_tag(), is_category() and is_tax(). These are sometimes combined into a single conditional statement in WordPress core, and there are plenty of examples on GitHub where developers have created an umbrella is_term() function like this:

function is_term($term = '') {
    return is_tag($term) || is_category($term) || is_tax($term);
}

It would be nice to have that function added to WordPress core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment