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.
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
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
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.
| Code | Meaning |
|---|---|
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 $registry | Receives the object supplied by Voxycure. Do not instantiate it yourself. |
$registry->register_taxonomy(...) | Adds this taxonomy definition to that registry object. |
#Taxonomy fields explained
| Key | What to enter | What it changes |
|---|---|---|
project_type | A stable machine name | The taxonomy key used by templates and WordPress APIs. Keep it lowercase and no longer than 32 characters. |
name | Plural label | Displayed as “Project types” in WordPress. |
singular_name | Singular label | Displayed when referring to one “Project type”. |
post_types | Post type slugs | Connects the taxonomy to project. The post type must also be registered. |
hierarchical | true or false | true behaves like Categories with parent/child terms; false behaves like Tags. |
show_in_rest | true | Makes terms available to the block editor and REST API. |
show_admin_column | true | Adds a Project types column to the Projects list. |
rewrite_slug | URL base | A term such as “Web” can use /work/type/web/. |
args | Native argument array | Adds or overrides advanced WordPress register_taxonomy() arguments. |
#4. Add and assign terms
- Refresh the WordPress dashboard.
- Open Projects → Project types.
- Add terms such as Web, Mobile, or Branding.
- 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
$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; ?>#6. If the taxonomy URL returns 404
Open Settings → Permalinks and click Save Changes once after adding or changing a rewrite slug. Do not flush rewrite rules on every request.
#Official WordPress references
- register_taxonomy() — native arguments, reserved terms, and slug rules.
- get_the_terms() — retrieve terms assigned to a post.
- add_action() — understand the callback used by
voxycure/register.