WordPress. get_taxonomy()

How to get taxonomy by: slug, id, name etc.

<?php
    // More info: https://developer.wordpress.org/reference/functions/get_terms/


    // Get taxonomy id from slug
    $taxonomy_slug = 'slug';
    $term          = get_term_by('slug', $taxonomy_slug, 'category'); 

    // Get taxonomy id from slug
    $taxonomy_id   = id;
    $term          = get_term_by('id',  $taxonomy_id, 'category')

    // Name and ID
    $name          = $term->name; 
    $id            = $term->term_id;
?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *