Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Product Catalog using Custom Post Types WordPress

I am working on setting up a product catalog using WordPress (latest version) and could use some help strategizing the best approach and setting up the custom post types and taxonomies. What I'm looking for is a hierarchical product catalog, much like an e-commerce store, but using WordPress custom post types:

+ Catalog
- Category One
- Product Page
- Product Page
- Category One
- Product Page
- Product Page
- Category One
- Product Page
- Product Page

I'd like the catalog (i.e. to display a list of the categories. Once a category is selected (i.e. you would see a listing of those products in that particular category. Selecting a product would bring you to the single-page for that item (i.e.

I've setup a custom type (products) and a taxonomy, which I'm calling product-categories.

register_post_type('products', array( 'label' => 'Products','description' => 'GVS products and services.','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => true,'rewrite' => array('slug' => 'products'),'query_var' => true,'has_archive' => true,'menu_position' => 6,'supports' => array('title','editor','excerpt','trackbacks','revisions','thumbnail','author',),'labels' => array (
'name' => 'Products',
'singular_name' => 'product',
'menu_name' => 'Products',
'add_new' => 'Add product',
'add_new_item' => 'Add New product',
'edit' => 'Edit',
'edit_item' => 'Edit product',
'new_item' => 'New product',
'view' => 'View product',
'view_item' => 'View product',
'search_items' => 'Search Products',
'not_found' => 'No Products Found',
'not_found_in_trash' => 'No Products Found in Trash',
'parent' => 'Parent product',
),) );

register_taxonomy('product-categories',array (
0 => 'products',
),array( 'hierarchical' => true, 'label' => 'Product Categories','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => 'products'),'singular_label' => 'Product Category') );

Is this a good strategy for what I'm attempting to accomplish? And, how do I create a category page that displays the taxonomy product-categories listed alphabetically (i.e.

Answers (4)


Abdessamad Idrissi answers:

Yes this is the right way to go: using taxonomies.
For how to display them, I'm working on something for you :)

Abdessamad Idrissi comments:

So you will need to create the file "[[LINK href=""]]taxonomy.php[[/LINK]]" inside of it put this:

$args = array(
'post_type' => 'products',
'orderby' => 'title'

query_posts( $args );

if(have_posts()) :

while(have_posts()) : the_post();

// show rhe product content


echo 'no products found';

modify the code as it suites you :)

Abdessamad Idrissi comments:

you can edit the args to show products ordered by title, ascending and 20 products per page:

$args = array(
'post_type' => 'products',
'orderby' => 'title',
'order' => 'asc',
'posts_per_page' => 20

Joe comments:

Thanks for your quick reply.

I see how you're creating a loop to pull the custom (product) posts, however that doesn't display the products by category (I don't think). I can display the products without regard to the taxonomy product-categories by going to This template file is archive-products.php.

What I'm ultimately trying to do is create a listing of the custom product posts and product-categories. I'd like the code to be flexible and allow for hierarchical products and categories. I've illustrated it the best I can in the attached image.

Maybe I'm making this more complex then it needs to be?