Home › Forums › Add-ons › Repeater Field › Repeater Plugin – Group By Help › Reply To: Repeater Plugin – Group By Help
So may be this example may help:
$posts = get_posts(array(
'post_type' => 'event',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'location',
'value' => 'melbourne',
'compare' => '='
),
array(
'key' => 'location',
'value' => 'sydney',
'compare' => '='
)
)
));
if($posts)
{
foreach($posts as $post)
{
// ...
}
}
Or maybe something like this (untested):
$rows = $wpdb->get_results($wpdb->prepare(
"
SELECT *
FROM wp_postmeta
WHERE meta_key LIKE %s GROUP BY meta_key ASC",
'Locations',
""
));
I’d be inclined to look at some examples. Maybe try running the SQL in PHPMyAdmin and then convert that into the code you need.
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.