Skip to content

Instantly share code, notes, and snippets.

@agragregra
Last active February 6, 2021 18:40
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 50 You must be signed in to fork a gist
  • Save agragregra/eb962af841825399ff57 to your computer and use it in GitHub Desktop.
Save agragregra/eb962af841825399ff57 to your computer and use it in GitHub Desktop.
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<p>Tag: <a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> </p> ';
}
}
?>
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
foreach($tags as $tag) {
echo '<p>' . $title . '<a href="' . get_term_link( $tag, 'post_tag' ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> has ' . $tag->count . ' post(s). </p> ';
}
}
?>
@harshclimate
Copy link

I tried this and it's exactly what I need, but when there's a tag used multiple times the tag will repeat the same amount of times the tag is used. Any way around that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment