![]() |
I want a page that displays an overview of the product categories. It's like a category top-level page I guess. But WooComm is confusing me (which is not hard).
I'm not trying to display the products of the category - that is already handled by WooComm's taxonomy-product_cat.php file, and it works fine. Be it a custom page template, or any solution that works(!), the page simply needs to display ....
(for each product category)
- product_cat title
- product_cat description
- product_cat image
- link to product_cat page
So if there are 2 product categories (shorts and jumpers) this page will show ....
Shorts Category Title
- shorts category description
- shorts category image
- link to shorts category page
Jumper Category Title
- jumper category description
- jumper category image
- jumper category page
Solution - 1This isn't directly supported by the WordPress hierarchy - you need to create your own template file and then use [[LINK href="http://codex.wordpress.org/Function_Reference/get_terms"]]get_terms[[/LINK]] with product_cat as the taxonomy argument to get a list of the terms. In a loop of the array that is returned, you can use [[LINK href="http://codex.wordpress.org/Function_Reference/get_metadata"]]get_metadata[[/LINK]] to retrieve the extra info you want for each (you get description and slug from the get_terms call, however the image url is stored in a custom meta table) and output as desired. You could create the template with a custom permalink added to the rewrite rules and then grab that in the template redirect function to route to your template file. However, you may find it easier to create a page template and an empty page with that template assigned to it. |
Wordpress |
Type: | Code Example |
Category: | Coding |
Sub Category: | Code Example |
Uploaded by: | Admin |
Views: | 10 |