Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle to remove category base from taxonomies #686

Open
sybrew opened this issue Aug 2, 2024 · 9 comments
Open

Toggle to remove category base from taxonomies #686

sybrew opened this issue Aug 2, 2024 · 9 comments
Assignees
Labels
[Impact] Growth Changes helping the plugin grow, not necessarily helping the current users. [Type] Feature Something new we need to write from the ground up.
Milestone

Comments

@sybrew
Copy link
Owner

sybrew commented Aug 2, 2024

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.

@sybrew sybrew added [Type] Feature Something new we need to write from the ground up. [Impact] Growth Changes helping the plugin grow, not necessarily helping the current users. labels Aug 2, 2024
@sybrew sybrew added this to the 5.1.0 milestone Aug 2, 2024
@sybrew sybrew self-assigned this Aug 2, 2024
@sybrew sybrew changed the title Toggle to remove category base from posts Toggle to remove category base from taxonomies Aug 2, 2024
@datgausaigon
Copy link

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

@datgausaigon
Copy link

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
Copy link
Owner Author

sybrew commented Aug 7, 2024

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
Copy link

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
Copy link

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

@sybrew
Copy link
Owner Author

sybrew commented Aug 12, 2024

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
Copy link

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
Copy link

chuckreynolds commented Sep 26, 2024

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.

@sybrew
Copy link
Owner Author

sybrew commented Nov 3, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Impact] Growth Changes helping the plugin grow, not necessarily helping the current users. [Type] Feature Something new we need to write from the ground up.
Projects
None yet
Development

No branches or pull requests

3 participants