Ebuka Val
  • Blogging
    • Affiliate Marketing
    • Artificial Intelligence
    • Blogging and Niche Websites
    • Monetization
    • WordPress
  • E-Commerce
    • Amazon FBA
    • Dropshipping
  • Make Money
    • Make Money Online
    • Self Publishing
    • Sidehustles
    • Start A Business
  • Social Media
    • Facebook
    • Instagram
    • Pinterest
    • TikTok
    • YouTube
  • Free ToolsNew
    • YouTube Tools
      • YouTube Title Generator
      • YouTube Tag Extractor
      • YouTube Tag Generator
      • YouTube Description Generator
      • YouTube Earnings Calculator
    • Website Management Tools
      • AdSense Revenue Calculator
      • Keyword Suggestion Tool
      • Robots.TXT Generator
      • Meta Tag Generator
      • Hosting Checker
      • WordPress Theme Detector
    • Text Analysis
      • Article Rewriter
      • URL Rewriter
Notification Show More
Latest News
Best AI Story Generators for content creation
5 Best AI Story Generator Tools for Content Creation: Ranked and Reviewed
Artificial Intelligence
adnow vs adsense
NEW! AdNow vs AdSense: Detailed Comparison for Publishers
Monetization
Best About Us Page Generators
9 Of the Best About Us Page Generators using AI (2023 Review)
Artificial Intelligence
How to Install WordPress Using CPanel
How to Install WordPress Using cPanel with & without Softaculous (2023 Guide)
WordPress
Tips to Secure and protect Your WordPress Website
10 Tips to Secure and Protect your WordPress Website in 2023
WordPress
Aa
Aa
Ebuka Val
Search
  • Blogging
    • Affiliate Marketing
    • Artificial Intelligence
    • Blogging and Niche Websites
    • Monetization
    • WordPress
  • E-Commerce
    • Amazon FBA
    • Dropshipping
  • Make Money
    • Make Money Online
    • Self Publishing
    • Sidehustles
    • Start A Business
  • Social Media
    • Facebook
    • Instagram
    • Pinterest
    • TikTok
    • YouTube
  • Free ToolsNew
    • YouTube Tools
    • Website Management Tools
    • Text Analysis
Have an existing account? Sign In
  • About Us
  • Blog
  • Contact Us
  • Terms & Conditions
Learn From a Bunch of Tutorials available for Free.
We may receive a commission for purchases made through links in this post. However, this does not impact our reviews and comparisons.
WordPress

How to Add Category to Custom Post Type (Easiest Method)

Ebuka Val
Last updated: 2022/09/17 at 4:17 PM
Ebuka Val Published September 17, 2022
Share
5 Min Read
How to Add Category to Custom Post Type
How to Add Category to Custom Post Type
SHARE

In this article, you’ll learn how to add unique categories to your Custom Post Type using the register taxonomy method. 

The default posts menu and its content on the left navigation menu are called the Custom Post, if you want to add or different type of post that is separate from your post, then you need to create a Custom Post Type. 

In the custom post type, we have an option to add tags, and we also have an option to add a Category. If you don’t want to use this feature, you can always exclude it or you can use what’s already existing in your current default posts categories. 

Before we get into the Business of the day, you need to have a Child Theme installed, for this tutorial, I’m going to be using Divi Child Theme. 

Creating a Custom Post Type 

If you wish to create a Custom post type, you need to however on Appearance from. The left navigation menu and then click on Theme Editor. 

Once the Theme Editor is open, locate your functions.php file by scrolling through the right navigation options, you should then paste in the code below: 

register_post_type(
    'press',
    array(
        'labels' => array(
            'name' => 'Press',
            'singular_name' => 'Press',
          
        ),
        'public' => true,
        'publicly_queryable' => true,
        'has_archive' => false,
        'rewrite' => array('slug' => $data['press_slug']),
        'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'page-attributes'),
        'can_export' => true,
    )
);

When the code above is live on your site, it will create a custom post type labeled Press. Do note that you can change it to whatever name you want your Custom Post Type to bear and you can create as many as possible by simply duplicating the code above. 

You can also add as many labels as you wish, refer to the WordPress Documentation for further Intel and how it all works. 

I have an in-depth article on How to Create Custom Post Types specifically, make sure to read it and gain the knowledge. 

How to Inherit Categories from Post 

We will register unique categories for that specific custom post type that we’ve created ‘press’. 

To do that, we’ll be utilizing the Register Category Method, you can do so by adding these codes to your Child Theme’s functions.php file: 

register_taxonomy('press_category', 'press', array('hierarchical' => true, 'label' => 'Categories', 'query_var' => true, 'rewrite' => true));
register_taxonomy('press_tags', 'press', array('hierarchical' => false, 'label' => 'Tags', 'query_var' => true, 'rewrite' => true));

Now, you can use whatever naming convention you manage to come up with for your taxonomy, it could be something like press_cat or presscat. 

Remember that if you want to change your custom post type name, you have to do so in all the lines of code listed in this article. 

You can simply paste the codes to your functions.php file, then use CTRL + F to find press, and then replace it with your CPT Name. 

Once you refresh your website and then hover on the Custom Post Type on the Left Navigation Menu, you should see the Tags and Categories option. 

How to Add Categories to Custom Post Type 

In the Categories Sub-menu under your Custom Post Type, you can always create your custom post type’s unique categories. This applies to every single custom post type you create using this tutorial. 

If you don’t want to host multiple custom categories on your website, you can always use the code below (remember to remove the Register Category Codes): 

'taxonomies' => array('category', 'post_tag'),

The code displayed above will enable your Custom Post Type to inherit the current categories of your default posts. 

Final Thoughts 

With this tutorial, you should be able to add categories or categories to your Custom Post Type(s) easily as I’ve provided all the necessary codes you need.

If you have a lot of Custom Post Types on your WordPress Website, then you should consider bringing them together under 1 function, so you can easily falk them when you want to edit, remove or customize further. 

You’d probably be interested in these resources:

  • How to Create Custom Post Types in WordPress (Without Plugins).
  • The Best Custom Post Type Plugins for WordPress.

Have any questions about Adding a Category to a Custom Post Type? Feel free to ask me in the comments and I’ll get back to you. 

Share this Article
Facebook Twitter Pinterest Reddit
Posted by Ebuka Val
Follow:
Hello! My name is Ebuka Val and I am a freelance SEO expert and writer. With years of experience in the industry, I have honed my skills in helping websites rank higher on search engines through effective search engine optimization techniques. In addition to my SEO work, I am also a writer and have written extensively on various topics related to blogging, affiliate marketing, and making money online. My passion for these topics has led me to create my own website, ebukaval.com, where I share my insights and strategies with my readers. I am constantly learning and expanding my knowledge in the digital marketing space, and I am always on the lookout for new opportunities to help businesses and individuals achieve their online goals. When I'm not working, I enjoy spending time with my family and exploring new hobbies. Thank you for taking the time to read about me, and feel free to contact me if you have any questions or would like to collaborate on a project.
Leave a review

Leave a review Cancel reply

Your email address will not be published. Required fields are marked *

Please select a rating!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

You Might Also Like

How to Install WordPress Using CPanel

How to Install WordPress Using cPanel with & without Softaculous (2023 Guide)

January 16, 2023
Tips to Secure and protect Your WordPress Website

10 Tips to Secure and Protect your WordPress Website in 2023

January 16, 2023
How to Upload and Install WordPress Plugins

How to Upload & Install a WordPress Plugin for Beginners

January 5, 2023
How to Insert Tables In WordPress Easily

How to Insert a Table in WordPress without Plugins

January 5, 2023
Newsletter Subscription

Subscribe to our newsletter to get our newest articles instantly!

Ebuka Val
Follow US

© 2023 www.ebukaval.com - All Rights Reserved.

  • About Us
  • Blog
  • Contact Us
  • Terms & Conditions
mailchimp email
Join Us!

Subscribe to our newsletter and be the first to know about the latest tips, tricks, and trends in blogging, affiliate marketing, artificial intelligence, YouTube, and making money online. And also get Free Guides!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Lost your password?