0

I have a list of all tag. I want set a order for them, form example, as order of slug? Here is the code for get all tags.

<?php
$tags = get_tags();
foreach ( $tags as $tag ) {
    $tag_link = get_tag_link( $tag->term_id);
    $html .= "<a href='{$tag_link}' title='{$tag->name}' class='{$tag->slug}'>";
    $html .= "{$tag->name}</a>";
}
echo $html;
?>
4

You'll have to specify the order and the orderby parameters within get_tags(). If you want an ascending order by slug you can update youre code snippet this way:

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

There are also a lot of other parameter as you can see in the codex: http://codex.wordpress.org/Function_Reference/get_tags#Parameters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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