Home › Forums › Add-ons › Repeater Field › Repeater row in WPQuery issue
Hi,
So i have a repeater inside post-type ‘properties’ that stores Lot No and Auction Date for all the Auctions a property is in.
When going into an event page, say for 12th August it needs to list all of the properties in this auction in Lot No order.
When i use WP Query i’m doing it as so:
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'auctions_$", "meta_key LIKE 'auctions_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$args = array (
'post_type'=>'properties',
'post_status'=>'publish',
'posts_per_page'=> 40,
'paged'=> $paged,
'suppress_filters' => false,
'meta_query' => array(
'proparray' => array(
'key' => 'auctions_$_auction_date',
'value' => $today2,
'compare' => 'LIKE',
),
'lot-nos' => array(
'key' => 'auctions_$_lot_no',
'type' => 'NUMERIC',
),
),
'orderby' => array(
// 'auction-dates' => 'ASC',
'lot-nos' => 'ASC',
),
);
$wpb_all_query = new WP_Query($args);
My problem is that it’s picking up Lot Nos from other rows. So if a property has the following date:
Auction Date : 7th June 2020
Lot No: 2
Auction Date: 12th August 2020
Lot No: 14
It is picking up the auction date 12th August 2020, but ordering it as Lot No 2, NOT 14. I need it to match to the specific row of the date in question, then get the Lot No from that row. is this possible?
Hi,
So i have a repeater inside post-type ‘properties’ that stores Lot No and Auction Date for all the Auctions a property is in.
When going into an event page, say for 12th August it needs to list all of the properties in this auction in Lot No order.
When i use WP Query i’m doing it as so:
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'auctions_$", "meta_key LIKE 'auctions_%", $where);
return $where;
}
add_filter('posts_where', 'my_posts_where');
$args = array (
'post_type'=>'properties',
'post_status'=>'publish',
'posts_per_page'=> 40,
'paged'=> $paged,
'suppress_filters' => false,
'meta_query' => array(
'proparray' => array(
'key' => 'auctions_$_auction_date',
'value' => $today2,
'compare' => 'LIKE',
),
'lot-nos' => array(
'key' => 'auctions_$_lot_no',
'type' => 'NUMERIC',
),
),
'orderby' => array(
// 'auction-dates' => 'ASC',
'lot-nos' => 'ASC',
),
);
$wpb_all_query = new WP_Query($args);
My problem is that it’s picking up Lot Nos from other rows. So if a property has the following date:
Auction Date : 7th June 2020
Lot No: 2
Auction Date: 12th August 2020
Lot No: 14
It is picking up the auction date 12th August 2020, but ordering it as Lot No 2, NOT 14. I need it to match to the specific row of the date in question, then get the Lot No from that row. is this possible?
@adamsuper were you able to figure this out? I have the same issue.
I don’t thing you can orderby the subfields of a repeater, but I could be wrong. This would require altering the ORDERBY part of the query similar to the way the WHERE part of the query is altered on the ‘posts_where’ hook. I have never seen any examples of doing this.
You must be logged in to reply to this topic.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.