Home › Forums › General Issues › How can the following wp query be sorted by a custom field? › Reply To: How can the following wp query be sorted by a custom field?
Another try based on
<?php $news_cat_ID = get_cat_ID( 'Datos de Contacto' ); $news_cats = get_categories( "parent=$news_cat_ID" ); foreach ( $news_cats as $news_cat ) : $news_query = new WP_Query( array( 'cat' => $news_cat->term_id, 'posts_per_page' => 1, 'no_found_rows' => true, 'ignore_sticky_posts' => true, 'meta_key' => 'region_contacto', 'orderby' => array( 'meta_value_num' => 'ASC', 'modified' => 'DESC' ) )); ?> <?php while ( $news_query->have_posts() ) : $news_query->the_post() ?>
Not sure what to try next..
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
💻 The next ACF Chat Fridays features a live demo of one of our most highly-requested features: registering CPTs and custom taxonomies directly in ACF. Don’t miss it!— Advanced Custom Fields (@wp_acf) February 27, 2023
📆 Friday 3rd March 3pm UTC
👉 Register here - https://t.co/3UtvQbDwNm pic.twitter.com/j4r4ouQtz9
© 2023 Advanced Custom Fields.