How to sort tag archive chronologically?

Home Forums Calendar Products Events Calendar PRO How to sort tag archive chronologically?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1110398
    Jessica
    Participant

    Hi there. I need to be able to show my users one specific event tag in chrono order. I read elsewhere in the forum that reverse chrono is the default, but this is not helpful to my users. Is there a workaround?

    Example: http://ballastandbuoy.com/tag/grief/

    #1110709
    Andras
    Keymaster

    Hello Jessica,

    Thanks for reaching out! Let me try to help you with this one.

    Paste this code in your functions.php file (Appearance > Editor > choose functions.php on the right side):


    /* CHANGE CHRONOLOGICAL ORDER OF TAG QUERY */
    // Runs before the posts are fetched
    add_filter( 'pre_get_posts' , 'change_tag_order' );

    // Function accepting current query
    function change_tag_order( $query ) {
    // Check if the query is for tags
    if($query->is_tag )
    // Query was for tags, then set order
    $query->set( 'order' , 'asc' );

    // Return the query (else there's no more query, oops!
    return $query;
    }

    Please note, this might also change the order of the blog posts, if those are called by tag.

    Let me know if this helps.

    Cheers,
    Andras

    #1116488
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How to sort tag archive chronologically?’ is closed to new replies.