Skip to content

Instantly share code, notes, and snippets.

@yuriitaran
Created November 10, 2017 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriitaran/2218311b04a2f3808c2b7b3764004e20 to your computer and use it in GitHub Desktop.
Save yuriitaran/2218311b04a2f3808c2b7b3764004e20 to your computer and use it in GitHub Desktop.
WP: Display Post Tags ordered by ID
// Display Post Tags ordered by ID
function show_post_tags_ordered_by_id($post_id) {
$args = array(
'orderby' => 'term_id',
);
$tags = wp_get_post_tags( $post_id, $args );
$html = '<div class="tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
$html .= "{$tag->name}</a>";
}
$html .= '</div>';
echo $html;
}
// Template.php
<?php show_post_tags_ordered_by_id($post->ID); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment