Home Forums General Issues orderby date picker field in get_terms Reply To: orderby date picker field in get_terms

  • Scenario 1

    If I’m understanding correctly, no, you cannot do this. You want to reorder the “terms” in a taxonomy based on a date edited when adding a “post”. You can’t order the terms according to something associated with the posts in those terms. To do this you would need to build something custom to somehow record the most recent date of all of the posts in a term and store that information in a way that is related to the term so that you can then use the date added to the term to order the terms.

    1. acf/save_post priority > 10
    2. get the term of the post being saved
    3. get the post in the term with the most recent date
    4. update the term using term meta with this date
    5. add a meta_query to your get terms call to sort them by this new term meta key

    Scenario 2

    You already have most of this, you just need to add a meta_key and order by the meta key in your query.