How to create custom post type with taxonomy in WordPress

In this post, I am going to explain how to create custom post type with category/taxonomy  in WordPress without any plugin.

There are lots of plugin available for custom post type and taxonomy but if you want to create without any  plugin,then needs to follow given steps.

You can create custom post in two ways first use  below code in your active theme functions.php file or create new own plugin and paste below code in your plugin file.

Example:-




Now save file and check in admin new post type book is registered. you can create lots of custom post according to need using register_post_type(‘post_type_name’,$args); function.
This function takes two parameters first post type name and second array type.

Now for category/taxonomy WordPress provided predefined function register_taxonomy( ‘book-category’, array( ‘book’ ), $args ); 

This function adds or overwrites a taxonomy. It takes in a name, an object name that it affects, and an array of parameters. It does not return anything.

Example:- Please copy the below code and paste it in your active theme functions.php file.

If you want create multiple categories for single post then you can create lots of category there are no restriction in WordPress you can create lots of category like author,publication etc.

custom taxonomy/category

 

13 thoughts on “How to create custom post type with taxonomy in WordPress”

  1. Hello, the whole thing is going nicely here and ofcourse every one is sharing
    facts, that’s truly good, keep up writing.

    Reply
  2. I simply needed to thank you very much yet again. I do not know the things that I might have used in the absence of the entire creative concepts discussed by you directly on that field. Certainly was a real frustrating concern in my circumstances, however , seeing the specialised strategy you handled that made me to leap with fulfillment. I will be happy for your assistance and thus have high hopes you comprehend what a powerful job you have been carrying out educating most people through the use of your websites. I am certain you haven’t encountered all of us.

    Reply
  3. I think this is one of the most vital info for me. And i am satisfied reading your article. But should commentary on few general issues, The website taste is wonderful, the articles is truly excellent : D. Excellent job, cheers

    Reply
  4. Hi, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

    Reply
  5. I simply want to mention I am just all new to blogs and definitely loved this web blog. More than likely I’m want to bookmark your website . You certainly have outstanding stories. Cheers for revealing your blog site.

    Reply
  6. These files are wonderful circumstances to customize the way the sport looks and they’re going to work well with Minecraft mods.
    All your belongings will be expecting you for any limijted
    timeframe, but they wait in places you died. Yes
    it’s a game buut after immersing yourself you’re feeling truly happy that youu might have madde who you are a
    great homje inside Minecraft.

    Reply

Leave a Comment