Content types

Register and use a taxonomy

A beginner-friendly, complete theme example that registers Project types and displays assigned terms.

#1. Create the theme files

This guide keeps registration code separate from the main theme file.

TEXT
your-theme/
├── functions.php
└── inc/
    └── voxycure.php

#2. Load the registration file

Add this to the active theme’s functions.php. WordPress loads that file automatically on every request.

PHP
<?php

defined('ABSPATH') || exit;

require_once get_theme_file_path('inc/voxycure.php');

#3. Register Project and Project type

Paste this entire example into inc/voxycure.php. It creates the post type and connects the taxonomy in one predictable callback.

PHP
<?php

defined('ABSPATH') || exit;

use Voxyframe\Core\Registry;

add_action('voxycure/register', function (Registry $registry): void {
    // Register the content type before connecting the taxonomy to it.
    $registry->register_post_type('project', [
        'name'          => 'Projects',
        'singular_name' => 'Project',
        'show_in_rest'  => true,
        'supports'      => ['title', 'editor', 'thumbnail'],
    ]);

    $registry->register_taxonomy('project_type', [
        'name'              => 'Project types',
        'singular_name'     => 'Project type',
        'post_types'        => ['project'],
        'hierarchical'      => true,
        'show_in_rest'      => true,
        'show_admin_column' => true,
        'rewrite_slug'      => 'work/type',
    ]);
});

#What $registry means

The anonymous function is your callback. Voxycure calls it and places its shared Registry object in the callback’s first parameter. That is why $registry exists inside the braces.

CodeMeaning
use Voxyframe\Core\Registry;Imports the class name so PHP can type-check the callback parameter.
add_action("voxycure/register", ...)Asks WordPress to run your callback when Voxycure is ready.
Registry $registryReceives the object supplied by Voxycure. Do not instantiate it yourself.
$registry->register_taxonomy(...)Adds this taxonomy definition to that registry object.

#Taxonomy fields explained

KeyWhat to enterWhat it changes
project_typeA stable machine nameThe taxonomy key used by templates and WordPress APIs. Keep it lowercase and no longer than 32 characters.
namePlural labelDisplayed as “Project types” in WordPress.
singular_nameSingular labelDisplayed when referring to one “Project type”.
post_typesPost type slugsConnects the taxonomy to project. The post type must also be registered.
hierarchicaltrue or falsetrue behaves like Categories with parent/child terms; false behaves like Tags.
show_in_resttrueMakes terms available to the block editor and REST API.
show_admin_columntrueAdds a Project types column to the Projects list.
rewrite_slugURL baseA term such as “Web” can use /work/type/web/.
argsNative argument arrayAdds or overrides advanced WordPress register_taxonomy() arguments.

#4. Add and assign terms

  1. Refresh the WordPress dashboard.
  2. Open Projects → Project types.
  3. Add terms such as Web, Mobile, or Branding.
  4. Edit a Project, select one or more Project types, and click Update.

The relationship is saved by WordPress in its native taxonomy tables. Voxycure does not create a custom table.

#5. Display terms in a theme template

Place this where a Project is being rendered, for example in single-project.php or a template part.

PHP
<?php

$terms = get_the_terms(get_the_ID(), 'project_type');

if ($terms && !is_wp_error($terms)) :
?>
    <ul class="project-types">
        <?php foreach ($terms as $term) : ?>
            <li>
                <a href="<?= esc_url(get_term_link($term)) ?>">
                    <?= esc_html($term->name) ?>
                </a>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

#Official WordPress references

Framework version2.0.0
PHP requirement8.0+
Documentation updatedAugust 2026