Toggle to remove category base from taxonomies
Add a feature to remove the category base from URLs via the Rewrite API.
It makes the link hierarchy more logical, which is helpful for visitors when navigating... and, therefore, also for SEO.
I often redirect users to this plugin, but given its prevalence as an SEO feature, we should also add it to TSF.
Hi @sybrew , Do you allow this new feature to support WooCommerce "product_cat slug base" and Custom Taxonomies? Thanks 🐻
I usually use https://wordpress.org/plugins/remove-cpt-base/ to remove the base slug of the Custom Post Type and keep the taxonomy base slug. If this feature is available, it will create many new conveniences in making our website. Customers often request to remove the taxonomy base slug.
Does your new feature depend on wp-cli wp rewrite flush?
Thanks
🐻
I always intend to support all custom post types with every feature I create, but this isn't always feasible.
WooCommerce already supports this feature out of the box. I don't know which version they added it to, but you can learn more about it here: https://woocommerce.com/document/custom-permalinks-for-woocommerce/.
I cannot give technical details about the planned feature yet because I still need to get started on it. I think the best way to implement this is by adjusting the WP_Rewrite API. So, yes, wp rewrite flush would be used for this, but I want to flush the rules automatically during plugin activating, deactivation, and toggling this setting.
With WooCommerce as you answered, they recommend a paid plugin: https://woocommerce.com/products/custom-permalinks-for-woocommerce/
We can refer to how they work.
I still hope that your new feature will support WooCommerce. It is a perfect integration and it also affects your new Breadcrumb feature.
You are right, other plugins that use the dependency on wp rewrite flush lack calling it in the cases like you said. And that leads to sometimes websites using those plugins getting 404 errors when querying pages that remove the base slug using WP_Rewrite API.
🐻
Hi, I found this plugin, I hope it can be of some help to you. https://wordpress.org/plugins/rewrite-testing/ 🐻
Thank you. I read over the part where a paid plugin was required for this.
I am already versed in Rewrite Rules, but thanks for giving pointers. Basically, everyone's doing it wrong thanks to harmful code from StackOverflow and StackExchange, and the API doesn't appear to get fixed.
All this is why TSF doesn't create rewrite rules since 2019:
[...] this addresses another issue in the WordPress ecosystem: Race conditions in the WordPress rewrite rules. [...] the gist is that whenever another plugin author made a mistake, either of our implementations failed, almost at random.
It's essentially why I kept dismissing this feature and redirected users to another plugin.
However, this ticket might've addressed some issues in WP 6.4 and higher: https://core.trac.wordpress.org/ticket/58998.
Hi,
Thanks for the explanation.
I think this new feature should have a mandatory requirement, which is to only work from WordPress 6.4 and above.
To use something new, we need to optimize the infrastructure and the system that follows. This ensures that the new feature works well and stably, avoiding many issues that we have known.
🐻
jumping in to +1 this feature for production release and get on the notifications train for this one. Very much would like to see this in the plugin :) Thx
EDIT:
I tested out the no-category-base plug and it removed too much.
My permalink struct: /blog/%postname%/
- what I have now:
/blog/category/foocat/ - what I want:
/blog/foocat/ - no-category-base plugin does:
/foocat/
So with that said, is my use case, and hopefully the functionality being considered for this issue.
Per @chuckreynolds's request, I created a snippet based on how Yoast SEO handles it, and I could only find myself stumping on rewrite issues. Maybe I've created a fault in the fork, but maybe it has always been broken.
Here's the snippet: https://github.com/sybrew/tsf-snippets/blob/main/permalinks/remove-category-base.php. For testing, you can generate a plugin from the snippet via this link: https://tsf.fyi/snippet/get/permalinks/remove-category-base.
Hi, I found this plugin, I hope it can be of some help to you. https://wordpress.org/plugins/rewrite-rules-inspector/ 🐻
Testing locally... The snippet at /permalinks/tsf-remove-category-base.php works to change /blog/category/foocat/ to /blog/foocat/ but doesn't handle 301.
PR1 submitted https://github.com/sybrew/tsf-snippets/pull/1