WordPress create custom post types with tags and categories

0

If you’re working with wordpress sometimes you want to add custom post types with it’s tags and categories to add into admin panel.For a example, “News” custom post type.You can follow this tutorial guide to add unique custom post types with it’s tags and categories to admin panel.No errors,no tags and categories mixing with other post types.No usages of plugins.

Features

  • Unlimited Custom post types
  • No mixing with other post types
  • Creating unique tags and categories
  • No usages of plugins
  • Simple and efficient code
  • Customize display columns
  • Custom admin menu icon
  • Sort column by post name
  • Filter posts by categories

Now we’ll see how to add custom post type to wp admin panel.
-First you must go to the theme folder and open the functions.php file.If you’re using premium themes you can use custom-functions.php or theme-function.php.
-After that at the end of the file put the following piece of code.Here I’m using “News” custom post type.

 

Step-1

After add the above code you can see the changes as following.

custom post types

Further note:
If you want to add custom menu icon go to following link and select the icon.Then copy it’s name(Ex:-dashicons-format-aside) and put here.
Dashicons

Step-2

Main part is finished.Now we’ll add it’s categories.Note here,I’ll explain little bit mistake many user’s doing.
If you add following mentioned code, you can see categories mixing with other post type’s,default post’s categories.So DON’T USE Following code. ‘taxonomies’ => array(‘category’) ,// mixing with others.

This is the correct code.

 

Step-3

Now we have to do the customize columns as the following diagram.
custom post types columns

Add the following code to functions.php file.

 

Step-4

Filter news and sort by name.
To do that add this code.

 

Step-5

Adding Tags to Custom post type. You can add following code to add tags to News post types.No mixing with other post types.

Now you have implemented all codes and after that you can see custom post types with tags and categories,sorting,filtering functions.
custom post types all

Additional Notes:
If you want to add more admin menu icons then add this code to functions.php file.

Follow my another post describing this.

Download full source code

Share.

About Author

Sumith Harshan is the Web Engineer Specializes in Java Script, JQuery, HTML4/5, CSS2/3, PHP, CodeIgniter, CakePHP, J2SE, J2EE, XML, Hacking & Security, Mobile Interface Developing, Magento, Wordpress, Joomla, Drupal,PHPBB,Facebook App Developing and Open cart...etc.