Registering Custom Taxonomy for Pages

  • iftekhar
  • May 6, 2014
  • 0 comment
  • 1462 Views
  • Print

Registering custom taxonomy can help site admins to organize their contents. Usage of post categories and tags are one such feature that we already know about. In one of my post, I have discussed how to register a taxonomy and showed how assign it for Custom Post Type(CPT) or even for native Posts.

Now, there are ways to register custom taxonomy for pages as well. This is how you should go about that.

<?php
// register taxonomy for pages
add_action('init','ib_taxonomy_for_pages');
function ib_taxonomy_for_pages() {
   register_taxonomy('type','page',array(
      'label' => 'Type',
      'rewrite' => array('slug' => 'type'),
      'hierarchical' => true )); }
?>

At this point all you need to do is to copy this snippet on your theme’s “functions.php” page and update it. Now, login to the back-end of your site and refresh the page. You should see the taxonomy under the “Pages” menu. From there you can create different terms and assign them with your pages, just like the way you did for posts. That’s all. Hope that helps.

  •  
  •  

Comment

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.