Support

Account

Home Forums General Issues Trying to ORDER foreach loop by ACF field Reply To: Trying to ORDER foreach loop by ACF field

  • Not sure I understand the question.

    You say that you want to order categories but you are adding the orderby statement to a post query.

    1) There isn’t any way using get_categories()/get_terms() to order terms by a CPT.

    2) There isn’t any way using WP_Query() to order posts based on a field that in not saved in as post meta for posts. In this case these values would be saved in term meta for the term.

    If your field is on the term then trying to short posts by a non existent meta key will result in no results found. When you specify the meta key the way you have it implies that the meta key must exist.