Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6004621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:17:19+00:00 2026-05-23T01:17:19+00:00

So my WordPress CMS has come quite a long way (and I’ve learned quite

  • 0

So my WordPress CMS has come quite a long way (and I’ve learned quite a bit about WordPress. I’ve created a custom post type called Products which is here:

add_action( 'init', 'create_product_post_type' );

function create_product_post_type() 
{
    $labels = array(
        'name' => _x('Products', 'post type general name'),
        'singular_name' => _x('Product', 'post type singular name'),
        'add_new' => _x('Add New', 'product'),
        'add_new_item' => __('Add New Product'),
        'edit_item' => __('Edit Product'),
        'new_item' => __('New Product'),
        'view_item' => __('View Product'),
        'search_item' => __('Search Products'),
        'not_found' => __('No products found'),
        'not_found_in_trash' => __('No products found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Products'           
        );

    $args = array(
        'label' => __('Products'),
        'labels' => $labels,
        'public' => true,
        'can_export' => true,
        'show_ui' => true,
        '_builtin' => false,
        'capability_type' => 'post',
        'menu_icon' => get_bloginfo('template_url').'/functions/images/product.png',
        'hierarchical' => false,
        'rewrite' => array( "slug" => "product" ),
        'supports' => array('title'), //MAYBE add thumbnail later!
        'show_in_nav_menus' => true

        );

        register_post_type( 'product', $args);  
}

Then a custom taxonomy called Category which is here:

function create_productcategory_taxonomy() {
    $labels = array(
        'name' => _x( 'Categories', 'taxonomy general name' ),
        'singular_name' =>_x( 'Category', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Categories' ),
        'popular_items' => __( 'Popular Categories' ),
        'all_items' => __( 'All Categories' ),
        'parent_item' => null,
        'parent_item_colon' => null,
        'edit_item' => __( 'Edit Product Category' ),
        'update_item' => __( 'Update Product Category' ),
        'add_new_item' => __( 'Add New Product Category' ),
        'new_item_name' => __( 'New Product Category' ),
        'separate_items_with_commas' => __( 'Separate categories with commas' ),
        'add_or_remove_items' => __( 'Add or remove product categories' ),
        'choose_from_most_used' => __( 'Choose from the most used categories' )
        );

    register_taxonomy('productcategory', 'product', array (
        'label' => __('Product Category'),
        'labels' => $labels,
        'hierarchical' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'product-category'),
        )); 
}

I created a single page in the wp-admin menu called Products that has a custom template I made. Going to http://localhost/project/products brings it up and it lists all the products post types. I also made a page for single-products.php that displays a single product post type details.

What I’m not sure how to do is create a way to filter my products by the custom taxonomy Category that is above. Let’s say I have a product that is a Widget. This Widget has a Category of ‘Spring Loaded’. If I wanted to view the single widget, I can just link to http://localhost/project/products/widget and it would bring up the single-product.php page and display the Widget as I formatted the page to do so. But I would like to link to just the ‘Spring Loaded’ category and list all my products in that custom category. I believe every category has it’s own slug (spring-loaded for example). If I go to http://localhost/project/product-category/spring-loaded it brings up a page but I dont’ know which file it is loading, other wise I could modify the output. Right now it loads each product as a normal post (with the date, comments, etc…).

So my question is how can I filter these categories? Or which file do I modify in order to change the output of the page that is linked from http://localhost/project/product-category/spring-loaded ?

I hope this makes sense. Thank you!

UPDATE:
Ahhhh. It’s making sense now. I changed this:

 register_taxonomy('productcategory', 'product', array (
        'hierarchical' => true,
        'rewrite' => array( 'slug' => 'product-category'),
        ));

to this:

 register_taxonomy('productcategory', 'product', array (
        'hierarchical' => true,
        'rewrite' => array( 'hierarchical' => true),
        ));

Even though I’m not sure what it does exactly.

I also created a taxonomy-productcategory.php and did some quick formatting and testing but it does indeed work. I can go to http://localhost/project/productcategory/ and it will list all of the products for that category.

Now do I need to change my rewrite rules like you did? I honestly don’t understand how htaccess works so I dont’ know if I need to change it or not. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:17:20+00:00Added an answer on May 23, 2026 at 1:17 am

    This pretty much the same problem I’ve few weeks ago.
    It already answered on WordPress.SE: https://wordpress.stackexchange.com/questions/14451/taxonomy-terms-and-template-files

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My mobile site (tiny custom CMS inspired by wordpress) has a homepage, blog page,
I am using wordpress CMS and when i am post a new post by
I am almost done with my humble attempt at a custom CMS using Wordpress.
This question is about WordPress cms. How to create a new admin user with
Has anyone ever modified the post-new.php file in their WordPress installation? I want to
I have to upgrade a running wordpress site's wordpress CMS and some installed plugins.and
I want to create a php page on the website (CMS Wordpress), but I
I am using wordpress as my cms and building a website. I use Graphene
I just started out using wordpress as a CMS. On the site I have
I'm new to WordPress. I have my site (CMS) divided to several pages in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.