1

In wordpress the tags are display alphabetically by default. How can I sort the tags by slug value and keep that order in the front end?

1 Answer 1

1

You can set orderby slug like :

$tags = get_tags( 'order=ASC&orderby=slug' );

$html = '<div class="post_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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.