-
Hi,
I’ve got a few products that show in 2 categories, but the category slug is not using the parent category that I’ve selected, it’s showing the 2 category that isn’t selected.
The primary field is set to product category in the settings. What can I do to make it take the proper category?
Many thanks,
Nick
-
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
“Primary category” functionality is offered by the Rank Math plugin. WooCommerce does not have this option by default and if you want to display “Primary category” in the breadcrumb, I suggest you use the Rank Math’s Breadcrumb functionality.
You can activate the breadcrumbs setting in Rank Math from Rank Math > General Settings > Breadcrumbs.
Then add the Rank Math’s breadcrumbs code to your theme’s template files, and the breadcrumbs will appear on your website’s front-end accordingly.
/** * Use the following code in your theme template files to display breadcrumbs: */ <?php if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); ?>
Paste the above code directly into your theme’s
single.php
orheader.php
wherever you prefer showing it.Here is a guide that might help you:
https://rankmath.com/kb/breadcrumbs/#add-breadcrumbs-themeHope this helps.
Looking forward to helping you. Thank you.
Hi Kamlesh,
Thanks for coming back to me. So that would be how to get the actual URL slug showing correctly? As in, at the moment it shows as:
https://www.lathamssteeldoors.co.uk/bin-store-doors/security-louvred-steel-door/
the /bin-store-doors/ is actually the secondary category so it should be showing as:
https://www.lathamssteeldoors.co.uk/louvred-steel-doors/security-louvred-steel-door/
Will those changes you select help? The current breadcrumbs on the product are showing the correct path already, it shows as:
Home / Louvred Steel Doors / Steel Louvred Door (Security)
Which is how it should show, it’s the the actual URL that isn’t taking the primary category in.
Many thanks,
Nick
Hi Kamlesh,
I just wanted to follow up and see if there way anything else I could try?
Many thanks,
Nick
Hello,
I see that you want to update the permalink (URL) of the product here.
In this case, could you please follow the below steps:
1. First edit the product and ensure that the correct primary category is selected.
2. Next, please update the permalink of the product and check if the correct product URL is generated or not?
You can change the Permalink by clicking on the “Edit” button right below the Product Title.
Please have a look at the below screenshot for your reference –
Hope this helps.
Looking forward to helping you.
Thank you.
Hi Kamlesh,
Thanks for coming back to me. So the actual product name part of the URL is correct, it’s the category part of the URL that isn’t referencing the primary category selection properly (when there is more than one category selected), it’s a function that works fine in Yoast, but I can’t get it to work here.
Many thanks,
Nick
Hello,
Could you please follow the below-mentioned steps:
1. First, please head over to your WordPress Dashboard > Settings > Permalinks, under Product Permalinks, choose Custom Base.
2. Enter the variable
/%product_cat%/
in Custom Base.3. Next, edit the product whose URL you want to update and ensure that the correct primary category is selected. Update the product.
4. Check if the correct URL is displayed in the Address bar.
Looking forward to helping you.
Thank you.
Hi Kamlesh,
Thanks for coming back to me, I think we might be getting our wires crossed a bit.
What I’m trying to do is replicate the function like Yoast has, whereby if you have a product in more than one category that whichever one you select as primary category in the list will be the one that gives the product it’s category slug part.
Is this possible in Rankmath?
Many thanks,
Nick
Hi there
I have the same problem as Nick mentioned, as kamleshe discussed I think he didn’t recognized the problem. it is not breadcamp or one product problem.instead of showing Chosen main product category, I have subcategory links in the permalinks. there should be a general solution for this problem. I have more than 3000 products that cant be changed the link one by one.
Any solution please help us.I was using yoast and it was perfect on that matter, now things are mixed.
ThanksHello,
I can check that it is working fine on my end. The primary category is being included in the product URL. Please make sure to update the product after selecting a primary category. Here is a quick screencast: https://i.rankmath.com/52VVUi
Please check and let us know if you need any further assistance.
Thanks.
Hi Jaideep,
Thanks for that, that’s exactly what i’m looking for. For some reason though, on mine it won’t actually assign the selected primary category as you can see here:
https://www.loom.com/share/a9d59f4884894cbdaa929c9922602dbfThe primary category should be the ‘louvred-steel-doors’ one, not the ‘bin-store-doors’ one. Is there anything that would be preventing this from happening?
Many thanks
Hi Jaideep,
I think I’ve actually found the cause, and it’s a conflict the Premmerce Permalink Manager plugin, which we use to remove the base category slug from our URL’s.
Is there a way round having to disable it, as it will ruin all the URL’s sitewide for our website.
Many thanks,
Nick
Hello,
Since the plugin is causing conflict with Rank Math’s functionality then you will have to get in touch with their support as they will be in a better position to help you fix the issue.
Also, if you use that plugin only to remove the category base then Rank Math also has the feature that allows you to remove the category base from the URL. For WooCommerce products, please navigate to WP Dashboard > Rank Math > General Settings > WooCommerce > Remove Category Base.
Hope this helps. Let us know if you need any other assistance.
Thanks.
Hi Jaideep,
I have raised it with them to see what they can come back with.
I would actually prefer to use Rankmath only, but the problem we have is that it can’t remove the parent category on a sub-category URL which is what premmerce does for us, so for example we would have
http://www.website.co.uk/parent-category/sub-category/product
and what we actually need is:
http://www.website.co.uk/sub-category/product
We had a similar issue with another one of our sites we launched in Australia, and had to bring premmerce back in to allow for that. Is there any potential for this feature to be added?
Many thanks,
Nick
Hello,
Unfortunately, Rank Math only removes the category base at the moment, so you can use third-party plugins to remove the parent category. Please let us know how that goes.
Looking forward to helping you.
Thank you
Hi Azib,
Thanks for your reply. Do you have an examples of other plugins other that Premmerce that allow this functionality?
Many thanks,
Nick
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.
The ticket ‘Primary category URL slug not correct’ is closed to new replies.