WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#42717 closed defect (bug) (fixed)

get_category_link() accepting object but not id

Reported by: belbo Owned by: 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
21 months 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 21 months ago by chetan200891 (previous) (diff)

#2 @rabmalin
21 months ago

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

term_id is the correct parameter for taxonomy.

#4 @netweb
21 months ago

  • Milestone Awaiting Review deleted

#5 @boonebgorges
21 months 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
21 months 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
21 months 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
21 months ago

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