WordPress.org

Ready to get started?Download WordPress

Forums

"Category" based permalinks for custom "Products" post type (6 posts)

  1. Julian Guy
    Member
    Posted 2 years ago #

    Hello,

    I've created a custom post type using register_post_type called "products" which will be used for holding about 1000 different products. The products are assigned to categories such as "Bathroom furniture > storage" or "Taps". I've got everything working nicely in the admin area but now i'm writing the templates i'm a bit stuck on how to achieve the permalink structure. Here's what i'd like:

    1. /products - display an archive page of the complete product range (paginated)
    2. /products/CATEGORY - this would list all products in that category as well as any child sub-categories
    3. /products/CATEGORY/SUBCATEGORY - this would list all products in that sub-category
    4. /products/CATEGORY/SUBCATEGORY/PRODUCTSTUB - the actual product

    I started off creating a template called archive-products.php to show the first view and that works fine.

    Next I made single-products.php and that works fine for the 4th view.

    The next thing I tried was changing the category base in the setting > permalinks section of the wp-admin area to "products". This get's me really close with views 1-3 all working perfectly but that breaks the 4th view.

    Can anyone help me get the 4th view working?

    Any help much appreciated!

    Julian

  2. nsathees
    Member
    Posted 2 years ago #

    check the permalink under settings in admin page. make sure the wordpress can write to your wp root folder as it will create the .htaccess file.

    once done secure the .htaccess file.

    One more question? how did you import all that content? did you use xl2wp plugin?

  3. Julian Guy
    Member
    Posted 2 years ago #

    Thanks for reply. The .htaccess file is definitely working. I need help achieving the above structures for permalinks, specifically view 4.

    Cheers
    Julian

  4. Julian Guy
    Member
    Posted 2 years ago #

    Has anybody got any ideas how to achieve this?

  5. markvanwijnen
    Member
    Posted 2 years ago #

    Were you ever able to figure this out? I want to achieve the exact same thing...

    I have a registered post_type project.
    And a taxonomy project_category

    Now I like my permalinks to turn out as

    1. /project - Overview of projects in all categories.
    2. /project/CATEGORY - Overview of projects within that category.
    3. /project/CATEGORY/SUBCATEGORY - Overview of projects within that subcategory.
    4. /project/CATEGORY/SUBCATEGORY/postname - The actual post.

  6. Julian Guy
    Member
    Posted 2 years ago #

    I'm afraid not. I had to settle on individual products having a
    /product/PRODUCTSTUB URL.

    I managed a kind of version of it by creating a page for each category and then creating a subquery in page.php to bring back posts based on the category. Obviously doesn't work well if you need to create new categories frequently.

    Let me kn ow if you solve it.

Topic Closed

This topic has been closed to new replies.

About this Topic