Skip to content [Tab]
~/posts/web/get-term-by-function-wordpress.md
$ stat -x get-term-by-function-wordpress.md POSIX filesystem
Access Mode: -rw-r--r-- (0644)
Author: uid:1000(@f7234bv9s8)
File Size: 717 B (66 words)
Modified:
Flags: --cat="web,wordpress"

WordPress. get_taxonomy()

attachment://featured-image.webp

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;
?>

@f7234bv9s8 maintainer

Software engineer and writer at notes:own:vision:com.