I would like to know if it is possible to make the tags of posts to appear by the order they were typed.

If it is possible, I would really appreciated to show me the details.

Many Thanks. Mario


To display post tags in order they were entered into WordPress, use this within the loop (returns a list of tag links):

echo '<ul>';
$tag_list = wp_get_post_terms(get_the_ID(), 'post_tag', array('orderby' => 'term_id', 'fields' => 'all'));
foreach($tag_list as $tag) {
    echo '<li><a href="' . get_term_link( $tag ) . '">' . esc_html( $tag->name ) . '</a></li>'; 
echo '</ul>';
  • Thank you for your reply, Is it possible to share with me where do I have to write this code ? (in which php page) Many Thanks Mario – Mario Gharib Apr 1 '17 at 12:17
  • Depends on your theme and where on your site you want to list the tags. You need to do it within the loop. First place to check is index.php – Industrial Themes Apr 1 '17 at 13:22
  • I actually figure out were to put the code, The problem we are facing now is the following: If I insert a new tag (Gamma) in a post, it will always appear first in all new posts, knowing that I want it to appear last, For example: In Post 1 the tags are: F. AZOURY, A. GHOSN, F. NASR, In Post 2 the tags are: M. HAIDAR, M. JREIGE, F. NASR, The problem is that "F. NASR" in post 2 will appear at first, since the tags are ordered by termi_ID, and I want it to appear at last. Is there a certain way to order tags independently in each posts ? – Mario Gharib Apr 4 '17 at 13:12
  • If you want latest tag to appear last, then order by ascending rather than descending by adding this to the array: 'order' => 'asc' – Industrial Themes Apr 4 '17 at 13:47
  • It is still not working. the code that is send will order them by 'term_id' so in this case is author#1 (term_id=1) was in article#2 the first, then author#1 (term_id=1) will always always appear the first in all the rest of the following articles, knowing that author#1 in certain articles should not be the first to appear – Mario Gharib Jun 22 '17 at 8:36

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.