What is Category In WP?

Category is one of the pre-defined taxonomies in WordPress. It is used to sort and group content into different sections. A website publishing content on a variety of topics can divide their website into sections using categories.

Example: A news website can have categories for articles filed under News, Opinion, Weather, Sports, etc.

If no category is specified for a post then the post is automatically filed into the default category. In a new WordPress installation, the default category is ‘Uncategorized’. A website administrator can change default category from Settings » Writing screen. A WordPress post can be filed under multiple categories and can have both categories and tags.

How to Add Categories

You can create a category in WordPress while writing a post. There is a categories meta box on the post editor screen with a list of existing categories. You can file your post in existing categories by checking the box next to the category name. You can also create one by clicking on the + Add New Category link.

You can also add a category directly from the Posts » Categories screen. Provide a name, and if you want you can add a Slug, which is a URL friendly name in lowercase and can only have letters, numbers, and hyphens. If you are creating a child category then choose a parent category. Provide a description for your category and click on Add New Category button. Only the category name is the required option to create a category and you can skip slug, parent, and description field if you want.


How to Display Categories

Categories can be displayed in the sidebar using categories widget. Go to Appearance » Widgets and drag and drop Categories widget to a sidebar. It will list all your categories in the sidebar, except for categories that do not have any posts filed under them.
You can also add categories to your website’s navigational menus. Go to Appearance » Menus. Click on categories, select categories and then click on Add to Menu button.

On the front-end of your WordPress website, each category has their own page. Most WordPress themes come with a template called category.php which controls the display of a category archive page. Each can also have their own template.

What is Child Category

Categories are a hierarchical taxonomy, meaning that each one can have child categories. A child category is usually used for a sub-topic under a broader topic.

Example: A news website may have a category News with child categories for Local, National, Global, etc.

You can add a child category while writing a post or from the categories screen. Just select a parent category when adding a new category and your new category will become child category.

How to Convert Categories to Tags

Categories and tags are both pre-defined taxonomies in WordPress. However, they are both different in scope. As for usage there are no restrictions, and you can have as many categories as you want. However, categories in WordPress are like broader sections of a website while tags are like keywords. Sometimes you may want to change your categories into tags or tags into categories. To do that, go to Tools » Import and click on Categories and Tags Converter. A pop-up window will open asking you to install the importer, click on the Install Now button. Once the importer is installed click on Activate Plugin & Run Importer.


How to Change the Howdy Text in WordPress Admin Bar


All you have to do is paste the following code in your theme’s functions.php file, or create a site plugin.

add_action( ‘admin_bar_menu’, ‘wp_admin_bar_my_custom_account_menu’, 11 );

function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );

if ( 0 != $user_id ) {
/* Add the “My Account” menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __(‘Welcome, %1$s’), $current_user->display_name );
$class = empty( $avatar ) ? ” : ‘with-avatar’;

$wp_admin_bar->add_menu( array(
‘id’ => ‘my-account’,
‘parent’ => ‘top-secondary’,
‘title’ => $howdy . $avatar,
‘href’ => $profile_url,
‘meta’ => array(
‘class’ => $class,
) );