📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials WordPress Development Taxonomies

Taxonomies

5 min read Quiz at the end
Custom taxonomies organise CPTs — hierarchical (categories-style) or flat (tags-style).

Custom Taxonomies

 ['name'=>'Skills','singular_name'=>'Skill'],
        'hierarchical' => false,  // false=tags, true=categories
        'public'       => true,
        'show_in_rest' => true,
        'rewrite'      => ['slug' => 'skill'],
    ]);
}
add_action('init', 'register_skill_taxonomy');

// Query by taxonomy
$query = new WP_Query([
    'post_type' => 'portfolio',
    'tax_query' => [[
        'taxonomy' => 'skill',
        'field'    => 'slug',
        'terms'    => ['php','react'],
        'operator' => 'IN',
    ]],
]);

// Taxonomy functions
get_the_terms($post_id, 'skill');
wp_set_object_terms($post_id, ['php','js'], 'skill');
wp_get_object_terms($post_id, 'skill');