How to Add Custom Tags Categories with Bangla Post Type

  • by
  • SEO
How to Add Custom Tags Categories with Bangla Post Type

Custom post type and taxonomies could be a great option to create a customized section for posts, categories, and tags. I already show How to create Custom Post Types for Bangla, and now I want to show the usage of custom taxonomies for WordPress. As like as the custom post type, you can also add custom taxonomies for Bangla tags and Categories. Here’s the process to add custom taxonomies that add the custom tags and categories with Bangla post type.

Step: 1 Creating Custom Tags and Categories

To added custom taxonomies as a custom category and tags to the custom post type, just open up your functions.php file and added the custom taxonomy and custom terms function. Thanks to the WordPress Official developer’s handbook, That I use to grab these codes and change them as needed.

Make sure to assign the custom taxonomies with custom post types by simply change the ‘taxonomies’ $args values for custom post types. Find this line from the custom post type function:

 ‘taxonomies’          => array( ‘category’, ‘post-tag’ ),

Now, change it as:

 ‘taxonomies’          => array( ‘Bangla-category’, ‘Bangla-tag’ ),

In this way, your custom categories and tags are assigns to custom post types for Bangla or Bangla posts. So, you can simply manage the Bangla categories and Bangla tags along with your custom post type.

However, it is just an example of the correct usage of custom post types and custom taxonomies, which you can quickly grab to use for any other purposes such as portfolio, product, recipe, or whatever you want. Make sure to assign them carefully with the appropriate post-type and taxonomies. Otherwise, that does not work as expected.

Step: 2 Customizing Custom Tags and Categories

Make a little tweak such as Taxonomy General Name, Taxonomy Singular Name as your desired name or purpose. For example, replace the “category” or “categories” phrase with “portfolio” or “portfolios.” Take a closer look at the codes from below for better understanding:

  ‘name’ => _x( ‘Categories’, ‘Taxonomy General Name’, ‘text_domain’ ),

Replace it with,

  ‘name’  => _x( ‘Portfolios’, ‘Taxonomy General Name’, ‘text_domain’ ),

Okay, I assume that it is good to explain the codes for better usage. That helps you to understand easily, exclude, include, or change any parts of these codes snippets.

// Register Custom Taxonomy
function custom_taxonomy() {
register_taxonomy( 'bangla-category', array( 'bangla' ), $args );
}
add_action( 'init', 'custom_taxonomy', 0 );

It is the main part of the code that I use to register a custom taxonomy.  Our function name is “custom_taxonomy”. You can also use “custom_taxonomy_bangla” or anything else for this purpose.

register_taxonomy( ‘Bangla-category’, array( ‘Bangla’ ), $args );

The main function that we use here. ‘Bangla-category’ is our taxonomy slug name. Remember that, it will not shows along with your particular posts unless you assign it to the particular post type. So, Here we assign it with the “Bangla” post type by using “array(‘Bangla’)”.

The value of “$labels = array();” is used for the admin area or back-end for name or leveling purpose. The value of “$args = array();” is defined by the other settings from the Administrator area.

Step: 3 Difference Between Custom Tags and Categories

In most cases, these are the default value. However, you can change this value. If you want to show up or display your Categories  as like as the default categories of WordPress, make it hierarchical by using the following codes:

‘hierarchical’               => true,

If you set it incorrectly, then your taxonomies are displayed as the default tags of WordPress. For Bangla tags, we already set it false. Find out the code snippets from the given text.

‘hierarchical’               => false,

Here, we explain a quick example of the usage of custom taxonomies as a category or post and showing you how to add custom Tags and Categories with Bangla Post Type. If you are looking for a detailed explanation and understanding, we recommend using the ‘codex developer handbook’ or stackexchange.com.

Leave a Reply

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

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