Question

I'm struggling to find a way to list all my tags without the current tag showing when i'm on a tag.php page. All I have is this, but it's not the current tag?

Était-ce utile?

La solution

You may try get_tags with exclude parameter. https://codex.wordpress.org/Function_Reference/get_tags

get_queried_object_id get the tag ID from tag page.

$tags = get_tags(array( 
    'exclude' => get_queried_object_id(), 
)); 

$tagList = array(); 

foreach($tags as $tag) 
{ 
    $tagList[] = '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a>'; 

} 
echo implode(', ', $tagList);
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange
scroll top