WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#29756 closed defect (bug) (duplicate)

get_tags() returns incorrect variable type in tag object

Reported by: jsavage37 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Taxonomy Keywords:
Focuses: Cc:

Description

I'm running a simple get_tags() and then looping through the tags as such:

<?php
$tags = get_tags();
global $wp_query;
foreach ($tags as $tag) :

    <a href="<?php echo get_tag_link((int)$tag->term_id); ?>"><?php echo $tag->name; ?></a>

<?php endif;
endforeach;
?>

See how I have to cast the term ID as an int? The doing a gettype($tag->term_id) revealed that the object itself was storing a string. After checking the documentation, that's supposed to be returned as a bigint.

Change History (1)

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Taxonomy
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #16101.

Note: See TracTickets for help on using tickets.