• Resolved jhoysi

    (@jhoysi)


    This plugin has been a lifesaver, but there’s one annoying thing that I can’t seem to figure out. I am using CPT UI as well, and have a hierarchical custom taxonomy set up. The issue is that the archive pages for the child terms repeats the parent’s term in the permalink.

    For example, I expect /products/power/double-conversion-ups/ and I’m instead getting /products/power/power/double-conversion-ups/

    Any ideas on how to fix this?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @jhoysi,

    Thank you for your message and involvement in development of plugin. It iss really helpful.

    Unfortunately, I can not repeat your issue. Can you help me? Would be great.

    I created a test environment for you. Try to repeat your issue and how you do it, describe me step by step what you did. I will be grateful for your help!

    Here are login details:

    https://demo-02.gbiorczyk.pl/wp-login.php
    jhoysi
    (HyNGvrM@dnlj4%#ZAssv@ZG

    Thank you in advance!

    Thread Starter jhoysi

    (@jhoysi)

    Thanks! I will work with this to recreate and send you an update.

    Thread Starter jhoysi

    (@jhoysi)

    I was able to recreate the issue. It’s a combination of WP Better Permalinks and using taxonomies as menu items in the site navigation. Here are the steps I used to create the problem:

    1. Install Custom Post Type UI (or create a custom post type and taxonomy):
    • Go to CTP UI > Tools. On the Post Type tab, paste the following to import the Products Category (to ensure we have the same settings): {"products":{"name":"products","label":"Products","singular_label":"Product","description":"","public":"true","publicly_queryable":"true","show_ui":"true","show_in_nav_menus":"true","show_in_rest":"false","rest_base":"","rest_controller_class":"","has_archive":"true","has_archive_string":"products","exclude_from_search":"false","capability_type":"page","hierarchical":"true","rewrite":"true","rewrite_slug":"products","rewrite_withfront":"false","query_var":"true","query_var_slug":"","menu_position":"21","show_in_menu":"true","show_in_menu_string":"","menu_icon":"dashicons-cart","supports":["title","editor","thumbnail","page-attributes"],"taxonomies":["product_category"],"labels":{"menu_name":"Products","all_items":"All Products","add_new":"Add New","add_new_item":"Add New Product","edit_item":"Edit Product","new_item":"New Product","view_item":"View Product","view_items":"View Products","search_items":"Search Products","not_found":"No Products Found","not_found_in_trash":"No Products Found in Trash","parent":"Parent Product:","featured_image":"Featured Product Image","set_featured_image":"Set Featured Product Image","remove_featured_image":"Remove Featured Product Image","use_featured_image":"Use as Featured Product Image","archives":"Product Archives","insert_into_item":"Insert into Product","uploaded_to_this_item":"Uploaded to this Product","filter_items_list":"Filter Products","items_list_navigation":"Products List Navigation","items_list":"Products List","attributes":"Products Attributes","parent_item_colon":"Parent Product:","name_admin_bar":""},"custom_supports":""}}
    • Click the Taxonomies tab at the top of the Tools panel. Paste the following to create the Product Category (to ensure we have the same settings): {"product_category":{"name":"product_category","label":"Product Categories","singular_label":"Product Category","description":"","public":"true","publicly_queryable":"true","hierarchical":"true","show_ui":"true","show_in_menu":"true","show_in_nav_menus":"true","query_var":"true","query_var_slug":"","rewrite":"true","rewrite_slug":"products","rewrite_withfront":"0","rewrite_hierarchical":"1","show_admin_column":"true","show_in_rest":"false","show_in_quick_edit":"true","rest_base":"","rest_controller_class":"","labels":{"menu_name":"","all_items":"","edit_item":"","view_item":"","update_item":"","add_new_item":"","new_item_name":"","parent_item":"","parent_item_colon":"","search_items":"","popular_items":"","separate_items_with_commas":"","add_or_remove_items":"","choose_from_most_used":"","not_found":"","no_terms":"","items_list_navigation":"","items_list":""},"meta_box_cb":"","object_types":["products"]}}
    • Create 3 Product Categories:
    1. Parent Category
    2. Child Category – set the parent as Parent Category
    3. Grandchild Category – set the parent as Child Category
    • Create a Product page. Give it a Product Category of Grandchild Category.
    • Install WP Better Permalinks
    • Set the Products URL structure to include Product Category
    • Create a Menu (Appearance > Menus) in the Primary menu location
    • Add all three Product Categories (you may need to turn on their visibility by opening the Screen Options panel at the top of the Menus page). Nest Child Category under Parent Category and Grandchild Category under Child Category to create a dropdown.
    • View the site and click on either Child Category or Grandchild Category from the dropdown. The URL structure will duplicate the parent/grandparent section of the URL.
    • Some additional notes/troubleshooting I’ve done:

    • In the Settings > WP Better Permalinks, turning off the taxonomy in the URL does not affect the performance of the taxonomies, but does break the permalinks to the eventual single Product – a 404 page shows.
    • Deleting the plugin outright resets the taxonomy URLs in the navigation, but the final single Product URL remains broken and results in a 404 page.
    • Reinstalling WP Better Permalinks and adding the taxonomy back to the URL structure settings <b>does</b> fix the single Product URL, but the taxonomy URLs from the menu repeat once again.
    • Setting the taxonomy URLs as custom URLs in the navigation does not help. There is a redirect created somewhere that forces the duplicate URL structure.
    • Adding a 301 redirect results in an infinite loop and crashes the site.

    Thanks for the help!

    Thread Starter jhoysi

    (@jhoysi)

    You can view the results of the above steps on the demo you created: https://demo-02.gbiorczyk.pl

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @jhoysi,

    Thank you for your waiting time. Probably I was able to find a solution. The problem lies in the “Rewrite Hierarchical” setting (on Taxonomies edition screen). The default value is false and this should remain.

    When you have it enabled, CPT UI plugin tries to generate a hierarchical link on its own – the same thing is done by my plugin and the problem arises. The only solution is to change this value to false.

    Try to do it. Uninstall and reinstall WP Better Permalinks plugin. Say if the problem was solved?

    Thread Starter jhoysi

    (@jhoysi)

    Thank you for your quick work! I have my computer in for repair, but will test as soon as I am able and will post the update here.

    Thread Starter jhoysi

    (@jhoysi)

    Yes, that solved it! Thank you for both taking the time, and for the explanation.

    Thread Starter jhoysi

    (@jhoysi)

    Marking resolved.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @jhoysi, Thank you also for your message and commitment. If you have a problem in the future, I will help you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Parent Taxonomy Slug Repeats on Archive Pages’ is closed to new replies.