Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created July 19, 2021 14:58
Show Gist options
  • Save hellofromtonya/e09c280ac2d0ec2743843f726456c620 to your computer and use it in GitHub Desktop.
Save hellofromtonya/e09c280ac2d0ec2743843f726456c620 to your computer and use it in GitHub Desktop.
Trac ticket 53165 - Test Custom Taxonomy added as a must-use plugin
<?php
// Location of this code: wp-content/mu-plugins/t53165.php.
namespace Test\t53165;
add_action( 'init', __NAMESPACE__ . '\register_test_taxonomy' );
function register_test_taxonomy() {
$labels = array(
'name' => 'Tests',
'singular_name' => 'Test',
'search_items' => 'Search Tests',
'all_items' => 'All Tests',
'parent_item' => 'Parent Test',
'parent_item_colon' => 'Parent Test:',
'edit_item' => 'Edit Test',
'update_item' => 'Update Test',
'add_new_item' => 'Add New Test',
'new_item_name' => 'New Test',
'menu_name' => 'Test',
);
$args = array(
'hierarchical' => true, // make it hierarchical (like categories)
'labels' => $labels,
'public' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'rewrite' => array( 'slug' => 'test' ),
);
register_taxonomy( 'test', array( 'post' ), $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment