Benefits of Custom Post Type or Taxonomy in WordPress

Grow your online business with us

Get A Quote

Benefits of Custom Post Type or Taxonomy in WordPress

With most of my TII’s projects based on WordPress, I had to eventually come across Custom post type or taxonomy sooner or later. Having worked with them on four projects, I guess the time has come to share with you the benefits of utilizing custom post type and taxonomies and where it shows its true potential. This will help you decide on using these powerful ways to create customized WordPress applications

vikas-sansoa

What are custom post types and taxonomies?

With the current position as one of the most popular and powerful content management systems in the world today, WordPress offers immense customization options. So while there are a number of in-built elements, WordPress facilitates developers to also create custom elements. This customization feature extends to post types and taxonomies too.

Custom post type defines what type is a particular content.

Taxonomy is a way in WordPress to group things together. This grouping mechanism extends to posts, links or custom post types

By default, WordPress provides the below elements

  1. Post types = posts, pages, nav menu, attachment and revisions
  2. Taxonomies = categories, tags, link categories and post formats

How to determine the need for a custom post type or taxonomy?

I was very much happy with the in-built post types and taxonomies. However, I have learned that by bringing in custom post types or taxonomies, I can add powerful functionality to the overall application. Adding these functionalities from the in-built elements might be very time-consuming or not possible at all.

Here are some varied situations where the need for custom post type or taxonomy will be justified –

  1. Providing a deal site or coupons portal
  2. Importing and managing list countries with its associated meta such as ISD codes, flags etc. (https://wordpress.org/plugins/countries/)
  3. A site where chronological ordering of articles is not needed
  4. A scenario where you cannot use the ‘categories’ and ‘tags’ taxonomies to group particular content
  5. Use custom post types instead of databases for WordPress e-commerce plugin (https://wpecommerce.org/)
  6. Adding custom meta boxes and fields
  7. Adding an image based slider (http://soliloquywp.com/) to the website

The value it added to my WP project

The need for custom post arose when I needed to provide a functionality to the user to work with movies, genre, star cast or ratings as a base. Thus my code looked something like this

function post_type_mov ()

{

register_post_type( ‘films’,

array( ‘label’ => __(‘Movies’), ‘public’ => true, ‘show_ui’ => true ));

register_taxonomy_for_object_type(‘post_tag’, ‘films’);

}

add_action(‘init’, ‘post_type_mov’);

 

This way, I can add a new movie and add all meta for this particular movie (cast, ratings, genre, similar to, comments etc.) Now, users can find information and carry out actions based on these meta fields. I can then add a taxonomy for ordering between ratings and actors. By adding in custom post and taxonomy, users can read only through the desired genres or actors, instead of going through ALL my posts within the website. This helps me in providing an enhanced UX/UI experience.

Write in to us with your comments and let us know how useful custom post type or taxonomy was in your WordPress development project. If this article helped you in your development work, do join us on social media with your valuable feedback.