By Mario Urdaneta


2019-06-12 23:46:01 8 Comments

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 comments

@Milan Hirpara 2019-06-13 04:31:49

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;

Related Questions

Sponsored Content

2 Answered Questions

Custom Post didn't display on tags page

2 Answered Questions

[SOLVED] Disable Woocommerce product tags display by alphabetical order

1 Answered Questions

[SOLVED] how to output tags that has specific value in slug

  • 2017-08-14 16:25:32
  • Andrew
  • 31 View
  • 0 Score
  • 1 Answer
  • Tags:   tags slug

3 Answered Questions

[SOLVED] Always show same size tags for Tag Cloud in Wordpress Admin

  • 2014-02-11 19:24:46
  • RCNeil
  • 2227 View
  • 1 Score
  • 3 Answer
  • Tags:   wp-admin tags

1 Answered Questions

[SOLVED] Order tags, but not alphabetically

  • 2015-01-10 03:34:06
  • Mr. B
  • 2326 View
  • 6 Score
  • 1 Answer
  • Tags:   tags order

1 Answered Questions

1 Answered Questions

How to create a second set of tags that use the same slug or URL?

1 Answered Questions

[SOLVED] sort tags by tag ID in admin panel

  • 2015-07-11 08:30:37
  • user3762572
  • 751 View
  • 1 Score
  • 1 Answer
  • Tags:   wp-admin tags sort

1 Answered Questions

Sorting terms individually for each post

Sponsored Content