WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19794 closed defect (bug) (fixed)

Rewrite rules for custom taxonomies not generated as permalinks are switched on

Reported by: duck__boy Owned by: duck_
Milestone: 3.4 Priority: normal
Severity: major Version: 3.3.1
Component: Rewrite Rules Keywords: has-patch
Focuses: Cc:

Description

The rewrite rules are not being created for any custom taxonomies when you select the 'Postname' structure. You must first select either 'Day and name' or 'Month and name' (but not 'Numeric'), save the permalink structure, and then select 'Postname' and resave.

I think selecting 'Numeric' fails for above method because none of the taxonomy rules are altered at all when you select 'Postname', so the ones that were created by 'Numeric' still start with 'archive/'.

Attachments (1)

19794.patch (584 bytes) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 scribu2 years ago

  • Cc scribu added

comment:2 follow-up: SergeyBiryukov2 years ago

Can't reproduce on a clean install. My steps:

  1. Set permalinks to "Post name".
  2. Create a custom taxonomy and assign it to a post. I've used Genres and Writers example from Codex with a minor adjustment: for standard posts rather than a book post type.
  3. Flush rewrite rules by visiting Permalink Settings screen (without changing the structure).
  4. The taxonomy archive (e.g. /genre/science-fiction/) is properly displayed.

comment:3 in reply to: ↑ 2 ; follow-up: duck__boy2 years ago

Replying to SergeyBiryukov:

Can't reproduce on a clean install. My steps:

  1. Set permalinks to "Post name".
  2. Create a custom taxonomy and assign it to a post. I've used Genres and Writers example from Codex with a minor adjustment: for standard posts rather than a book post type.
  3. Flush rewrite rules by visiting Permalink Settings screen (without changing the structure).
  4. The taxonomy archive (e.g. /genre/science-fiction/) is properly displayed.

Have you tried setting the permalinks to 'Default', to remove all rewrite rules, and then setting them back to 'Post name'? To my understanding, when you add a taxonomy the rules are flushed, so your steps would not see an error - it is only when you change the structure after creation.

comment:4 follow-up: dd322 years ago

Can you please do the following?

  1. Post an example piece of code to reproduce it (as simple as possible?) - A similar problem happens sometimes when the incorrect hooks are used
  2. Does hitting save twice on the permalinks page help?

comment:5 in reply to: ↑ 3 SergeyBiryukov2 years ago

Replying to duck__boy:

Have you tried setting the permalinks to 'Default', to remove all rewrite rules, and then setting them back to 'Post name'?

Just tried that. Taxonomy archive is only displayed then after saving the changes twice, as dd32 suggested. This seems to be the case for other (non-default) structures too, not just "Post name".

comment:6 in reply to: ↑ 4 duck__boy2 years ago

Replying to dd32:

Can you please do the following?

  1. Post an example piece of code to reproduce it (as simple as possible?) - A similar problem happens sometimes when the incorrect hooks are used
  2. Does hitting save twice on the permalinks page help?

I'm unable to post code, as this occurs in the admin panel under permalinks, not through code. And yes, saving it twice does seem to work.

comment:7 follow-up: dd322 years ago

I'm unable to post code, as this occurs in the admin panel under permalinks, not through code. And yes, saving it twice does seem to work.

But your custom taxonomies are added via code correct? It sounds like Sergey has duplicated however.

This sounds exactly like #16736 which was supposed to be fixed in 3.3

comment:8 in reply to: ↑ 7 duck__boy2 years ago

Replying to dd32:

I'm unable to post code, as this occurs in the admin panel under permalinks, not through code. And yes, saving it twice does seem to work.

But your custom taxonomies are added via code correct? It sounds like Sergey has duplicated however.

This sounds exactly like #16736 which was supposed to be fixed in 3.3

Sorry, yes taxonomies are added via code (register_taxonomy()), but that is not what this issue is about. And yes, sounds similar to the other ticket.

SergeyBiryukov2 years ago

comment:9 SergeyBiryukov2 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.4

Looks like #16736 wasn't really fixed. [18443] fixed #18040 for CPT, but the similar issue still exists for custom taxonomies.

19794.patch implements the same fix for register_taxonomy().

comment:10 duck_2 years ago

  • Owner set to duck_
  • Resolution set to fixed
  • Status changed from new to closed

In [19930]:

Taxonomy rewrite generation when turning on permalinks, r18443 for taxonomies. Props SergeyBiryukov. Fixes #19794.

comment:11 duck_2 years ago

  • Summary changed from Rewrite rules for custom taxonomies not being created for 'Postname' structure to Rewrite rules for custom taxonomies not generated as permalinks are switched on
Note: See TracTickets for help on using tickets.