Home › Forums › Add-ons › Repeater Field › Repeater Plugin – Group By Help › Reply To: Repeater Plugin – Group By Help
$plfsByState = $wpdb->get_results("
select pm.meta_value as state, count(*) as postcount
from $wpdb->posts p
join $wpdb->postmeta pm on p.ID = pm.post_id
where p.post_type = 'plfmaps'
and p.post_status = 'publish'
group by state
order by state ASC");
This gives me way too much data…And doesnt exactly work. This basically returns everything. I’m seeing div with the address, city, state. How can i modify this query to only show the states?
Where I am getting mixed up is the meta_key value for the location_state actually looks like this in the database table “locations_0_state” and “locations_1_state” — any ideas on this one? I feel like I am really close, but I’m missing something.
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.