WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 weeks ago

#36305 new defect (bug)

Permalink can't decide the parent category

Reported by: gr8shivam Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Permalinks Keywords:
Focuses: Cc:

Description

The bug:-
There is a bug in the permalink generation that it can't decide the parent category. This means that even though we choose the child & parent both as a post's category, it creates the permalink as /parent/child/ in certain situations.

Please note that the Permalink Structure is set to:-

/%category%/%postname%/

What should happen:-
If we choose a parent category as well as the child category as post's categories, the permalink should be:

/parent/

And if we choose only the child as post category, the permalink should be:

/parent/child/

Demonstration:-
I created a parent-child category set as "Parent 1 (parent) & Child 1 (child)" & another set as "Parent 2 (parent) & Child 2 (child)". The difference between the two sets is that 'Child 1' was created before 'Parent 1' & then edited to have 'Parent 1' as it's parent, while the 'Child 2' was created after 'Parent 2'.

Now, if I choose 'Parent 1' & 'Child 1' as a post's category, it creates the permalink as:

/parent-1/child-1/hello-world/

And if I choose 'Parent 2' & 'Child 2' as a post's category, it creates the permalink as:

/parent-2/hello-world/

How to reproduce the bug:-

  1. Create a category 'child 1'.
  2. Create another category 'parent 1'.
  3. Now edit the 'child 1' category and set 'parent 1' as it's parent.
  4. Now the permalink can't judge that 'parent 1' is the parent of 'child 1' & creates a wrong permalink as if only 'child 1' was selected.

Possible Reason:-
A possible reason for this bug maybe due to the category id. Here, the 'Child 1' has lesser category id than 'Parent 1'. And the permalink algorithm checks for the least selected category id.

Attachments (2)

PC-1.png (217.3 KB) - added by gr8shivam 3 years ago.
The Permalink generated on choosing Parent 1 & Child 1 as categories of a post.
PC-2.png (215.6 KB) - added by gr8shivam 3 years ago.
The permalink generated after choosing the Parent 2 & Child 2 as a post's categories.

Download all attachments as: .zip

Change History (4)

@gr8shivam
3 years ago

The Permalink generated on choosing Parent 1 & Child 1 as categories of a post.

@gr8shivam
3 years ago

The permalink generated after choosing the Parent 2 & Child 2 as a post's categories.

This ticket was mentioned in Slack in #core by mike. View the logs.


3 years ago

#2 @mikeschroder
3 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.