WordPress.org

Ready to get started?Download WordPress

Forums

Breadcrumb NavXT
[resolved] Small issue with breadcrumbs when viewing a single post (5 posts)

  1. stavros3006
    Member
    Posted 2 years ago #

    Hi mtekk,

    Thank a lot for this wonderful plugin, don't know what would I do without it. What I'm experiencing is not actually an issue, but it's rather a question of how to modify a certain thing. Here goes:

    I built a website for a client that has a products section. All the products are grouped based on categories and subcategories. The thing is that my client wanted to also have some explanatory static texts above each product page, so what I did was to go with pages. So, for each category I have set up a page with the same slug as the corresponding category and I'm using WP_Query to display products on a page from the matching category with the matching slug.

    Further on, each product is a single post and it belongs to Products as the main category and to its subcategory, for example, Shoes, and then Running Shoes.

    Here's an example of the Products structure:

    Products (main page)
    - Shoes (a subpage to Products)
    -- Running Shoes (subpage to Products and further on a subpage to Shoes)
    - Hoodies (a subpage to Products)
    etc.

    So, basically my structure consists of pages and subpages that each filter products from matching categories and subcategories when clicked. So, if I click on Products it will show ALL products, if I want to narrow it down to Shoes I click Shoes and it only shows shoes. So, here while I'm browsing through the pages and subpages the breadcrumbs work flawless. So, I have Products > Shoes > Running Shoes (in the address bar http://www.domain.com/products/shoes/running-shoes).

    But when I click on a certain single item, I go into the single post and this is where it all goes wrong. While I'm on a single post if I try to navigate with the breadcrumbs, it adds the category base in the URL becoming http://www.domain.com/category/products/shoes/running-shoes/adidas-stan-smith which leads me to a unformatted looking page as my categories don't have any templates applied to them as I'm going with pages.

    I know that this is the logic of how WordPress is generating the URL for categories, and that your plugin is using exactly that logic, but since my structure is made of pages and subpages is there a way I can make the breadcrumbs in the single post to behave the same as they are on the pages?

    Sorry for the excessive post, but I tried to describe my issue the best I could.

    Thanks a lot in advance!
    Best regards

    http://wordpress.org/extend/plugins/breadcrumb-navxt/

  2. John Havlik
    Member
    Plugin Author

    Posted 2 years ago #

    While I don't recommend doing things this way (there is a description field for taxonomy terms (categories, tags, and custom taxonomies) that may do what you want). I'd also recommend using a CPT for the product. But regardless of that, what you need to do is set the parent of the product posts to be that of the page you are using in place of your category. This mapping isn't done for you, but once you've done that, set the taxonomy type for the post type in question to "pages" in Breadcrumb NavXT's settings page.

  3. stavros3006
    Member
    Posted 2 years ago #

    Ok, thank you mtekk for your reply. I really appreciate it!

    But since I'm quite new to WordPress, and all I did for this website was just reading around blogs and tutorials of how to do things, can you please point me out in a sentence or two why you don't recommend doing things this way? Are there any consequences by doing a site this way?

    And if let's say, I go the right way and go with categories, how could I get rid of the category base http://www.domain.com/category/ in the URLs?

    Thanks a lot!

  4. John Havlik
    Member
    Plugin Author

    Posted 2 years ago #

    The fundamental problem you'll run into is that posts do not have pages as parents. Depending on how you do things it will become a maintenance nightmare as you try to add more products. You want WordPress to do the work for you and for category like things you should use a taxonomy of some sort (category, tag, or a custom taxonomy).

    Rather than try to rename categories, create a custom taxonomy. Use a name like products, or product categories and use a slug/rewrite of products. Then you'll be able to create your desired URL structure of domain.com/products/shoes/running-shoes/asics-gt2170

    I suggest reading http://mondaybynoon.com/20110520/revisiting-custom-post-types-taxonomies-permalinks-slugs/ for a guide on CPTs/custom taxonomies and WP_Rewrite

    Also, another option (a little less robust, but easier to implement), you could rename the category base to products from category (in your Settings > Permalinks page). Just make sure you aren't using categories for things like News items or blog posts.

  5. stavros3006
    Member
    Posted 2 years ago #

    Thank you mtekk, you've been more than helpful on the matter!

    I'm gonna mark this issue as resolved and do a further reading on the matter until I redo the website the way WordPress was meant to function.

    Keep up the good work and all the best!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic