Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#41647 closed defect (bug) (invalid)

The nicename argument in get_category_parents works the opposite way

Reported by: birgire's profile birgire Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Here's an example:

echo get_category_parents( 338, $link = false, $separator = '/', $nicename = false );

that outputs:

Animals/Cats/British Shorthair Cat/

and with $nicename = false it outputs

animals/cats/british-shorthair/

But it should be vice versa.

The reason is this check within get_category_parents():

$format = $nicename ? 'slug' : 'name';

https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/category-template.php#L50

but it looks like it should be:

$format = ! $nicename ? 'slug' : 'name';

Reading the old Codex page:

https://codex.wordpress.org/Function_Reference/get_category_parents

where it says:

$nicename
(boolean) (optional) Whether to use nice name for display. If set to true, the category slug will be used instead of the category name.
Default: false

I wonder if this vice-versa has just been accepted as is.

Hope I'm not misunderstanding things here.

Change History (3)

#1 @birgire
6 years ago

ps: I meant to write above:

... and with $nicename = true it outputs

animals/cats/british-shorthair/

#2 @birgire
6 years ago

  • Resolution set to invalid
  • Status changed from new to closed

ok, I it's me that got confused the nicename here ;-)

it's the slug that is usually meant as nicename.

This ticket should be deleted, so I mark it as invalid, thanks

#3 @SergeyBiryukov
6 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.