I am currently displaying a post tags in a sidebar, using the PHP Code widget and the following snippet:

if ( is_singular() ) :
    echo get_the_tag_list(
        '<div class="my-button-list" id="my-tags-list"><ul><li>',

Currently, these tags are ordered alphabetically; what I would like to do is maintain the order in which they are entered in the backend. I tried the approach that was suggested here for the_tags, but to no avail.

Any help with finding a similar or suggested approach would be much appreciated!

Best regards,



To display post tags in order they entered in the backend, use this within the loop where you want to display. Hope this will helps you to display your tag list.

Where, the tag were display in order based on their created term_id.

if ( is_singular() ) :
echo '<div class="my-button-list" id="my-tags-list">';
echo '<ul>';
$ordered_tag_list = wp_get_post_terms(get_the_ID(), 'post_tag', array('orderby' => 'term_id', 'fields' => 'all'));
foreach($ordered_tag_list as $tag) {
    echo '<li><a href="' . get_term_link( $tag ) . '">' . esc_html( $tag->name ) . '</a></li>'; 
echo '</ul>';
echo '</div> 
  • Thanks a lot for your help Suresh! That works perfectly for ordering the tags by their term_id, but that results in them being ordered by the time they were first created, rather than when they were added to the individual post. My intention is to have the most important tags for each specific post listed first, based on the order I enter them when creating said post. It's saved in that order on the post edit page in the backend, but I haven't found a way to display it as such on the frontend. Do you know of any way to alter your code to achieve that effect? – Segia May 10 '18 at 9:57
  • Okay, let me check if it possible to do what you have said. – Suresh Sapkota May 10 '18 at 13:25
  • 1
    After doing research, I haven't found any WP function to check & return which tag was first added to post. So, you have to write custom function for it. But, if I found any solution. I will post it. – Suresh Sapkota May 11 '18 at 17:10
  • That's what I feared - I couldn't find anything in the documentation myself either. In any case, thanks a lot for your effort! – Segia May 13 '18 at 10:20

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.