WordPress Custom Taxonomies Development

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Developing Custom WordPress Taxonomies

A taxonomy in WordPress is a classification system for posts. Built-in ones are "Categories" (hierarchical) and "Tags" (flat). Custom taxonomies are created for any other grouping: project technologies, job specialties, real estate types, film genres. A properly configured taxonomy provides URL-friendly links for each category, filtering in /wp-admin, and parameters for WP_Query. Registration takes a few hours; full setup with taxonomy meta-fields and custom archive pages takes 1 day.

Registration via register_taxonomy

add_action('init', function () {
    // Hierarchical taxonomy (like categories)
    register_taxonomy('project_category', ['project'], [
        'labels' => [
            'name'              => 'Project Categories',
            'singular_name'     => 'Category',
            'search_items'      => 'Search Categories',
            'all_items'         => 'All Categories',
            'parent_item'       => 'Parent Category',
            'parent_item_colon' => 'Parent Category:',
            'edit_item'         => 'Edit',
            'update_item'       => 'Update',
            'add_new_item'      => 'Add Category',
            'new_item_name'     => 'New Category',
            'menu_name'         => 'Categories',
        ],
        'hierarchical'          => true,
        'show_ui'               => true,
        'show_admin_column'     => true,
        'query_var'             => true,
        'rewrite'               => ['slug' => 'project-category', 'hierarchical' => true],
        'show_in_rest'          => true,
        'rest_base'             => 'project-categories',
    ]);

    // Flat taxonomy (like tags) — tech stack
    register_taxonomy('tech_stack', ['project', 'case'], [
        'labels' => [
            'name'          => 'Technologies',
            'singular_name' => 'Technology',
            'add_new_item'  => 'Add Technology',
            'search_items'  => 'Search Technologies',
            'all_items'     => 'All Technologies',
        ],
        'hierarchical'      => false,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => ['slug' => 'tech'],
        'show_in_rest'      => true,
    ]);
});

show_in_rest => true is necessary for the taxonomy to work in the Gutenberg editor. show_admin_column => true adds a column with terms to the post list.

Using in WP_Query

// Projects in "web" category with "react" tag
$projects = new WP_Query([
    'post_type'      => 'project',
    'posts_per_page' => 12,
    'tax_query'      => [
        'relation' => 'AND',
        [
            'taxonomy' => 'project_category',
            'field'    => 'slug',
            'terms'    => 'web',
        ],
        [
            'taxonomy' => 'tech_stack',
            'field'    => 'slug',
            'terms'    => ['react', 'next-js'],
            'operator' => 'IN',
        ],
    ],
    'orderby'        => 'date',
    'order'          => 'DESC',
]);

Meta-Fields for Taxonomy Terms

Starting with WordPress 4.4, taxonomy terms have meta-fields via add_term_meta/get_term_meta. Example: add an icon and color to a project category:

// Fields on term addition page
add_action('project_category_add_form_fields', function (string $taxonomy): void {
    ?>
    <div class="form-field">
        <label for="term-color">Category Color</label>
        <input type="color" id="term-color" name="term_color" value="#1a1a2e">
        <p>Color for display in lists and project cards</p>
    </div>
    <div class="form-field">
        <label for="term-icon">Icon (SVG code or dashicons class)</label>
        <input type="text" id="term-icon" name="term_icon" value="">
    </div>
    <?php
});

// Fields on term edit page
add_action('project_category_edit_form_fields', function (WP_Term $term): void {
    $color = get_term_meta($term->term_id, 'color', true) ?: '#1a1a2e';
    $icon  = get_term_meta($term->term_id, 'icon', true);
    ?>
    <tr class="form-field">
        <th><label for="term-color">Color</label></th>
        <td><input type="color" id="term-color" name="term_color" value="<?= esc_attr($color) ?>"></td>
    </tr>
    <tr class="form-field">
        <th><label for="term-icon">Icon</label></th>
        <td><input type="text" id="term-icon" name="term_icon" value="<?= esc_attr($icon) ?>"></td>
    </tr>
    <?php
});

// Save
add_action('created_project_category', 'save_project_category_meta');
add_action('edited_project_category', 'save_project_category_meta');

function save_project_category_meta(int $term_id): void {
    if (isset($_POST['term_color'])) {
        update_term_meta($term_id, 'color', sanitize_hex_color($_POST['term_color']));
    }
    if (isset($_POST['term_icon'])) {
        update_term_meta($term_id, 'icon', sanitize_text_field($_POST['term_icon']));
    }
}

Frontend usage:

$terms = get_the_terms(get_the_ID(), 'project_category');
foreach ($terms as $term) {
    $color = get_term_meta($term->term_id, 'color', true) ?: '#ccc';
    $icon  = get_term_meta($term->term_id, 'icon', true);
    printf(
        '<a href="%s" class="tag" style="--tag-color:%s">%s%s</a>',
        esc_url(get_term_link($term)),
        esc_attr($color),
        $icon ? '<span class="tag__icon">' . esc_html($icon) . '</span>' : '',
        esc_html($term->name)
    );
}

Custom Term Order

By default, terms are displayed alphabetically. For manual order, use term_order via plugin or meta-field:

add_action('edited_project_category', function (int $term_id): void {
    if (isset($_POST['term_order'])) {
        update_term_meta($term_id, 'order', absint($_POST['term_order']));
    }
});

// Sort on output
$terms = get_terms([
    'taxonomy'   => 'project_category',
    'hide_empty' => false,
    'meta_key'   => 'order',
    'orderby'    => 'meta_value_num',
    'order'      => 'ASC',
]);

Taxonomy on Multiple CPTs

One taxonomy can serve multiple post types—"tech stack" for both projects and cases. After registration, add a type to an existing taxonomy:

register_taxonomy_for_object_type('tech_stack', 'case');

Taxonomy Archive Template

WordPress finds the archive template by hierarchy: taxonomy-{tax}-{term}.phptaxonomy-{tax}.phptaxonomy.phparchive.php. In FSE themes—similarly via templates/taxonomy-project_category.html.

Performance

Queries on taxonomies with large numbers of terms and posts can be slow. Several rules:

  • Always use 'fields' => 'ids' in get_terms() if you need only IDs
  • With tax_query with multiple taxonomies—check query plan via EXPLAIN
  • For public filters with large archives—use Elasticsearch or cache results via Redis