Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42717 closed defect (bug) (fixed)

get_category_link() accepting object but not id

Reported by: belbo's profile belbo Owned by: boonebgorges's profile boonebgorges
Milestone: 4.9.2 Priority: normal
Severity: normal Version: 4.9
Component: Taxonomy Keywords: fixed-major
Focuses: Cc:

Description

I just updated to the latest version of WP and realised that some of my links stopped working. I was using

<?php
get_category_link($term->id);

which no longer works, however

<?php
get_category_link($term_oject);

Does work. According to the codex both should work :-)
https://developer.wordpress.org/reference/functions/get_category_link/

thanks :-)

Change History (8)

#1 @chetan200891
7 years ago

@belbo Welcome to Trac!

I think you should try

<?php
get_category_link($term->term_id);

instead of

<?php
get_category_link($term->id);

Because Term ID field returned as 'term_id' not 'id'.

Last edited 7 years ago by chetan200891 (previous) (diff)

#2 @rabmalin
7 years ago

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

term_id is the correct parameter for taxonomy.

#4 @netweb
7 years ago

  • Milestone Awaiting Review deleted

#5 @boonebgorges
7 years ago

  • Component changed from General to Taxonomy
  • Milestone set to 4.9.2
  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Version changed from trunk to 4.9

Reopening so as to be fixed as part of #42771.

#6 @boonebgorges
7 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from reopened to closed

In 42364:

Don't do a strict taxonomy check in get_category_link().

Prior to version 4.9, a quirk in the implementation of get_term() caused
get_category_link( 123 ) to fetch the taxonomy archive link for term 123
even if 123 is not in the 'category' taxonomy. The quirk was fixed in [40979];
see #40671. This bugfix introduced a regression for theme authors who were
expecting the old behavior.

By lifting the 'category' restriction, we allow the template function to work
in the old way.

Fixes #42717. See #42771.

#7 @boonebgorges
7 years ago

In 42369:

Don't do a strict taxonomy check in get_category_link().

Prior to version 4.9, a quirk in the implementation of get_term() caused
get_category_link( 123 ) to fetch the taxonomy archive link for term 123
even if 123 is not in the 'category' taxonomy. The quirk was fixed in [40979];
see #40671. This bugfix introduced a regression for theme authors who were
expecting the old behavior.

By lifting the 'category' restriction, we allow the template function to work
in the old way.

Merges [42364], [42365] to the 4.9 branch.

Fixes #42717. See #42771.

#8 @boonebgorges
7 years ago

  • Keywords fixed-major added
Note: See TracTickets for help on using tickets.