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
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
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 –
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.