X

Register taxonomy for your pages

This is a simple snippet that will register a custom taxonomy for pages. In the sample code I register a taxonomy called things but of course you would want to register something a little more realistic. You can find out more details about registering a custom taxonomy in the codex. Just add this snippet to the functions.php of your wordpress theme and you will see the new taxonomy displayed within the wordpress admin.



Code Snippet:


add_action( 'init', 'pages_tax' );
function pages_tax() {
register_taxonomy(
'things',
'page',
array(
'label' => __( 'Things' ),
'rewrite' => array( 'slug' => 'things' ),
'hierarchical' => true,
)
);
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!