sybrew / the-seo-framework

The SEO Framework WordPress plugin.
https://theseoframework.com/
GNU General Public License v3.0
420 stars 46 forks source link

Toggle to remove category base from taxonomies #686

Open sybrew opened 2 months ago

sybrew commented 2 months ago

Follow up from 685:

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.

datgausaigon commented 2 months ago

Hi @sybrew , Do you allow this new feature to support WooCommerce "product_cat slug base" and Custom Taxonomies? Thanks 🐻

datgausaigon commented 2 months ago

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 🐻

sybrew commented 2 months ago

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.

datgausaigon commented 2 months ago

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.

🐻

datgausaigon commented 2 months ago

Hi, I found this plugin, I hope it can be of some help to you. https://wordpress.org/plugins/rewrite-testing/ 🐻

sybrew commented 2 months ago

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.

datgausaigon commented 2 months ago

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. 🐻

chuckreynolds commented 1 month ago

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%/

So with that said, is my use case, and hopefully the functionality being considered for this issue.