WooCommerce: How to Display Product Categories – A Beginner’s Guide
So, you’ve got your WooCommerce store up and running, stocked with amazing products. Great! But how do you make it easy for customers to find exactly what they’re looking for? The answer is product categories! Displaying them effectively is crucial for a smooth user experience and ultimately, more sales. This guide will walk you through several ways to show off your product categories in WooCommerce, even if you’re a complete newbie.
Why Display Product Categories?
Think of your favorite online store. Chances are, it’s well-organized. You don’t have to scroll through hundreds of products to find what you want. That’s the power of categories. Here’s why displaying them is so important:
- Improved Navigation: Customers can quickly navigate to the section of your store that interests them most. Instead of searching for “red sweater,” they can simply click on “Sweaters” and then filter by “Color: Red.”
- Enhanced User Experience: A well-organized store is a pleasant store to shop in. Happy customers are more likely to buy something.
- Better SEO: Proper category structure helps search engines understand your store’s organization, which can improve your search ranking. Think of it as giving Google a roadmap of your shop!
- Increased Sales: By making it easy for customers to find products, you increase the chances of them finding something they want to buy. It’s like guiding them directly to the checkout!
- Title: Give your widget a title, like “Shop by Category” or “Browse Our Products.”
- Display as dropdown: Choose whether to display the categories as a list or a dropdown menu. Dropdowns are useful when you have many categories to avoid cluttering the sidebar.
- Show product counts: This will display the number of products in each category. This can be helpful for customers to gauge the size of each category.
- Show hierarchy: This will display subcategories nested under their parent categories. This is often essential for proper navigation.
- Order by: Sort categories alphabetically or by term ID (the order they were created).
- Hide empty categories: Choose whether to hide categories that don’t contain any products. A clean look is always preferable.
- Men’s Clothing (25)
- Shirts (10)
- Pants (8)
- Jackets (7)
- Women’s Clothing (30)
- Dresses (12)
- Skirts (9)
- Tops (9)
- `number`: The number of categories to display. `number=”-1″` displays all categories.
- `columns`: The number of columns to use for displaying the categories in a grid.
- `orderby`: The order in which to display the categories (e.g., “name,” “count,” “term_id”).
- `order`: The order direction (“ASC” for ascending, “DESC” for descending).
- `hide_empty`: Set to “1” to hide empty categories, “0” to show them.
- `parent`: Display only subcategories of a specific parent category. Use the parent category’s ID.
Method 1: Using the WooCommerce Product Category Widget
The easiest way to display product categories is by using the built-in WooCommerce Product Category widget. No coding required!
1. Go to Appearance > Widgets in your WordPress dashboard.
2. Find the “WooCommerce Product Categories” widget.
3. Drag and drop it into the sidebar or other widget area where you want to display the categories.
4. Configure the widget options:
5. Click Save.
Example: Imagine you’re selling clothing. Your product category widget might look like this:
Shop by Category
Method 2: Displaying Categories in Your Navigation Menu
Adding product categories to your main navigation menu is another great way to make them easily accessible.
1. Go to Appearance > Menus in your WordPress dashboard.
2. Select the menu you want to edit (usually your main menu).
3. In the “Add menu items” box on the left, find the “Product Categories” tab. If it’s not visible, click “Screen Options” at the top right of the page and make sure “Product Categories” is checked.
4. Select the categories you want to add to the menu. You can select individual categories or “View All” to add multiple at once.
5. Click “Add to Menu.”
6. Drag and drop the categories to arrange them in the desired order. You can also create sub-menus by dragging a category slightly to the right, nesting it under a parent category.
7. Click Save Menu.
Example: Your navigation menu might now have items like “Home,” “Shop,” “About Us,” and then your main product categories like “Men’s Clothing,” “Women’s Clothing,” and “Accessories.”
Method 3: Displaying Categories on a Specific Page (Using Shortcode)
Sometimes, you might want to display product categories on a specific page, like your homepage or a dedicated “Shop” page. You can do this using the `[product_categories]` shortcode.
1. Go to Pages > Add New (or edit an existing page) in your WordPress dashboard.
2. In the content editor, add the `[product_categories]` shortcode where you want the categories to appear.
3. Customize the shortcode with attributes to control how the categories are displayed.
Common `[product_categories]` attributes:
Example: To display all product categories in 3 columns, hiding empty categories, use this shortcode:
[product_categories number=”-1″ columns=”3″ hide_empty=”1″]
Reasoning: Using `number=”-1″` ensures all categories are shown regardless of the total number. `columns=”3″` arranges the categories neatly in three columns, providing a balanced visual appeal. `hide_empty=”1″` keeps the display clean and focused by removing categories without products.
Another Example (Showing Subcategories): Let’s say you have a category called “Electronics” with an ID of 15, and you only want to show the subcategories of “Electronics”. Use this shortcode:
[product_categories parent=”15″ columns=”2″]
Method 4: Custom Coding (For Advanced Users)
If you’re comfortable with PHP, you can create a custom function to display Check out this post: How To Change The Order Of Products In Woocommerce Storefront product categories exactly how you want. This gives you the most flexibility but requires coding knowledge.
Warning: Only attempt this if you understand PHP and WordPress theme development. Incorrect code can break your site.
Here’s a basic example you can adapt. This code can be added to your theme’s `functions.php` file or a custom plugin:
'product_cat', 'orderby' => 'name', 'show_count' => 1, // Show product counts 'pad_counts' => 1, // Include subcategory product counts in parent counts 'hierarchical' => 1, // Show hierarchical taxonomy 'title_li' => '', // Remove the default title 'hide_empty' => 1 // Hide empty categories );
echo ‘
- ‘; // Open a list
wp_list_categories( $args );
echo ‘
‘; // Close the list
}
// To display this in your template, use:
//
?>
Explanation:
- `$args`: This array defines the parameters for the `wp_list_categories()` function.
- `taxonomy`: Specifies that we’re working with the `product_cat` (product category) taxonomy.
- `orderby`: Orders the categories by name.
- `show_count`: Displays the number of products in each category.
- `pad_counts`: Includes the product counts of subcategories in the parent category’s count.
- `hierarchical`: Shows subcategories nested under their parent categories.
- `title_li`: Removes the default “Categories” title.
- `hide_empty`: Hides categories with no products.
- `wp_list_categories( $args )`: This function generates the Explore this article on How To Add Fancy Product Designer To Woocommerce HTML list of categories based on the `$args` array.
- `echo ‘
- ‘;` and `echo ‘
‘;`: These lines wrap the categories in a `
- ` (unordered list) element, making it easy to style with CSS.
How to use it:
1. Add this code to your theme’s `functions.php` file (or a custom plugin).
2. In your theme template file (e.g., `sidebar.php`, `page.php`), use the following code where you want to display the categories:
Styling:
You can then use CSS to style the `custom-product-categories` class to make the list look exactly how you want.
Key Takeaways
- Plan Your Categories: Before you even Discover insights on How To Show Woocommerce As Homepage start adding products, think about how you want to organize your store.
- Keep it Simple: Don’t create too many categories. Focus on broad, easily understandable classifications.
- Use Subcategories: Subcategories help you further refine your product organization.
- Regularly Review: As your store grows, review your categories and make adjustments as needed.
By implementing these methods, you can effectively display your WooCommerce product categories, improve your store’s navigation, and provide a better shopping experience for your customers. Good luck!