How to hide or style your subcategories in WordPress

How to hide or style your subcategories in WordPress

In WordPress, The content organization into categories and subcategories gives the post an attractive and catchy look. It also helps in SEO and navigation to easily find what the users want.

Subcategories are good, as they beautify and sort the content. However, a long list of subcategories does not always look good.

Therefore, We will discuss how to hide or style subcategories in WordPress. 

Why do we use subcategories?

Subcategory allows you to add subtopics to a category. The Categories are hierarchical to display subcategories in the parent category. Using them is not necessary, of course. However,  It develops a proper site structure that is meaningful.

For example, you can add  Electronics and post articles for computers, desktops, laptops, etc. This is the time to use subcategories. Electronics would become a parent category, computers become child categories or subcategories, and desktops and laptops become sub-sub categories.

If you want to display categories in the widget, you can use a hierarchy or flat list.

  • Go to Appearance, then Widgets. 
  • Now tick the ‘show hierarch’ box on the category widget.

You can see how a flat and hierarchy list looks like below:

How to hide or style your subcategories in WordPress

We know subcategories are suitable for sorting our content and giving a neat look to the post. But subcategories tend to appear ugly sometimes.

Consequently, We can hide or style subcategories by different methods. This article is for both the users, one who knows how to code and one who doesn’t. We’ll be doing this by using a single code snippet or plugin. 

How to hide subcategories by using CSS code

In this article, we will use CSS code snippets to hide our subcategories. You can directly add a snippet to your theme’s style.css file, or you can add them using the theme customizer in WordPress.

For beginners adding CSS could be tricky. Here is the method you can follow.

How to add custom CSS

Suppose you don’t know no how to add custom CSS. You can follow these simple steps.

  • Go to themes, then customize the page.

        Theme customizer interface will open with lots of options.

  • Click on the additional CSS from the left.

The tab will slide over with a simple box. You can add your custom CSS here, and it’s done. You will be able to see it on your website live view.

  • Now save and click publish button on the top.

At this time, you have successfully added custom CSS to your WordPress. Let’s continue the steps for hiding subcategories in WordPress.

  • You have to copy the below code and paste it into your theme’s style.css file or your WordPress theme customizer.
   .children {

    display:none;

    }

To use theme customizer, click 

  • appearance>>customize>>additional CSS 

Now, paste the above code and then click to publish button.

You can check the subcategories are hidden. 

How to style subcategories in WordPress using CSS code

In WordPress, you can style or customize the categories and subcategories. You can change the style of your subcategories by following the same steps used in hiding them.

  • Copy the code and paste it into style.css or the theme customizer.
 .children {

padding: 0 0 0 5px;

margin: 0 0 0 2px;

border-left: 1px solid #333;

}

If you are using the Theme Customizer, then don’t forget to click the Publish button.

You can check it on your WordPress site.

How to hide subcategories in WordPress using plugin

In order to tell you how to hide subcategories in WordPress, we will use the plugins.

Using Ultimate Category Excluder plugin

 The ultimate category excluder plugin gives us the option to exclude a category from the homepage of WordPress within a few steps.

  • Install and activate the “Ultimate Category Excluder.” plugin.

  • Go to Settings and click “Category Excluder.”

Here you can select which category you want to keep and exclude.

  • Click the category to remove from the “Front Page.”

  •  Click the Update option at the bottom of the page.

Now, the categories you selected are removed from the front page.

Front Page Category plugin.

The Front Page Category plugin is basic. It does not provide a lot of options as it simply removes categories you choose from the front page of your blog post. Although you want a tool that offers this feature, this plugin is for you.

Here, go to the category options from the Customizer in WordPress and uncheck the categories you don’t want to show.

Collapsing Categories List plugin.

The Collapsing Categories List plugin gives you many options. It helps you to customize your archives in WordPress.You can hide several categories here. Also, you can remove links and collapse subcategories by default.

Most of the features for this tool are available from the Widgets screen in WordPress.

To wrap up, This was all about how you can hide or style your subcategories in WordPress.This helps in content organization and gives a decent look to the WordPress site. You can do this by using CSS code or by plugins.

 

 

Leave a Comment