![]() |
I have made a custom post type (for my products) and a corresponding hierarchical taxonomy (a catalog for my products).
I have renamed category.php to taxonomy.php. It now shows all my products that belong to a certain category.
Now, since I have a lot of products, I don't want all of them listed on that page, I'd rather have them grouped by subcategory.
Let me give you an example: Say I sell clothing and my taxonomy looks like this:
- Pants
- - Loose Fit
- - Baggy Style
- Shoes
- - Leather
- - Suede
When taxonomy.php is called to show all pants, I'd like to have them listed like this:
- Loose Fit
- - Loose Pants #1
- - Loose Pants #2
(...)
- Baggy Style
- - Baggy Pants #1
- - Baggy Pants #2
(...)
Solution - 1Hello, I think I've cracked that. It's possible to query by custom taxonomies - it's just has not been documented yet. OK, I hope I've understood the question right. Here we go. I've used the default TwentyTen theme with a custom taxonomy called "Catalog" and post type called "Products". 1) Put this in functions.php 2) Put this in your taxonomy-catalog.php 3) Enjoy Please check out the result on my test site: http://test.druuf.com/wordpress/?catalogs=pants (parent category) http://test.druuf.com/wordpress/?catalogs=baggy-style (child category) Solution - 2Hi, You can further classified them using templates according to WordPress template hierarchy. taxonomy-{taxonomy}-{term}.php - If the taxonomy were sometax, and taxonomy's slug were someterm WordPress would look for taxonomy-sometax-someterm.php taxonomy-{taxonomy}.php - If the taxonomy were sometax, WordPress would look for taxonomy-sometax.phpThanks. Solution - 3I think you are in the situation to query posts by custom taxonomy... and that's not in WordPress, yet. You can do it with a custom select query. Something like this: And that is just for 2 terms... You then need to use a different loop; something like explained [[LINK href="http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query#The_Revised_Loop"]]here[[/LINK]]. Or, you can assign the default "category" taxonomy for your custom post type. Also, you won't have the custom taxonomy slug in the URL if you define your own taxonomy (something I discussed [[LINK href="http://themeforest.net/forums/thread/custom-post-typetaxonomy-permalinks/31585"]]here[[/LINK]]) Hope I understood your issue and this helps :) Solution - 4Its simple. even you can use your category.php file for your purpose. you just need to do setting in admin. it will display product only for selected category or subcategory whatever. Even you can also change the URL structure to your category and sub category name |
Wordpress |
Type: | Code Example |
Category: | Coding |
Sub Category: | Code Example |
Uploaded by: | Admin |
Views: | 8 |