Comments (12)
Here: https://support.advancedcustomfields.com/forums/topic/acf-countrycitystate-field/
from acf-city-selector.
Might be a good addition... will look into it...
I hope to push everything to master somewhere early this week.
from acf-city-selector.
BTW how did you find it ? Didn't really promote it yet...
from acf-city-selector.
All issues I mentioned there are fixed (afaik).
from acf-city-selector.
Somewhat unrelated question (I'm pretty new to this ACF thing, hope you can help):
I need to display an overview of all provinces (with total post count) and include a list of all cities that have posts attached (also with count, see image). How would you go about this with ACF fields?
from acf-city-selector.
This is a rough idea....
$post_args = array(
'post_type' => 'post_type',
'posts_per_page' => 999,
'meta_query' => array(
array(
'key' => 'sd_city_selector',
'compare' => 'EXISTS',
),
),
);
$posts_with_city_info = get_posts( $post_args );
if ( false != $posts_with_city_info ) {
$states_array = false;
$city_info = false;
foreach ( $posts_with_city_info as $post ) {
$field_value = get_field( 'sd_city_selector', $post->ID );
$city_info[] = $field_value;
$states_array[] = $field_value[ 'stateName' ];
}
if ( $states_array ) {
$no_double_states = array_unique( $states_array );
foreach ( $no_double_states as $state ) {
echo $state;
// get all array keys from $city_info where stateName == $state
// count unique values
}
}
}
I added comments where you still need to do some work, but i've been working too long today already :)
from acf-city-selector.
Ja top, hier kan ik wel iets mee.
Thanks!
from acf-city-selector.
Please post the result (if you found one), so someone else can also use it in case of need.
from acf-city-selector.
@gavinhewitt v0.1 has been released (and it has some minor fixes)
from acf-city-selector.
Thank you guys, for your ideas. I finished your code. May be not best, but works for me.
$post_args = array(
'post_type' => 'clinic',
'posts_per_page' => 999,
'meta_query' => array(
array(
'key' => 'sd_city_selector',
'compare' => 'EXISTS',
),
),
);
$posts_with_city_info = get_posts( $post_args );
if ( false != $posts_with_city_info ) {
$states_array = false;
$city_info = false;
foreach ( $posts_with_city_info as $post ) {
$field_value = get_field( 'sd_city_selector', $post->ID );
$city_info[] = $field_value;
$cities_array[] = $field_value[ 'cityName' ];
$states_array[] = $field_value[ 'stateName' ];
}
$clinics_in_city_counter = array_count_values($cities_array);
$clinics_in_state_counter = array_count_values($states_array);
if ( $states_array ) {
$no_double_states = array_unique( $states_array );
foreach ( $no_double_states as $state ) {
echo "<h3>" . $state . "</h3>";
echo $clinics_in_state_counter[$state]." клиник<br />";
foreach ( $city_info as $address_arr){
if ($address_arr['stateName']==$state){
$cities_of_state[]=$address_arr['cityName'];
}
}
$no_double_cities = array_unique( $cities_of_state );
echo "<ul>";
foreach ($no_double_cities as $city) {
echo "<li>" . $city . " " . $clinics_in_city_counter[$city]."</li>";
}
echo "</ul>";
$cities_of_state=array();
$no_double_cities=array();
}
}
}
from acf-city-selector.
Thank you for this, I will try to take a look at it when i have some time, but very busy this month.
from acf-city-selector.
This request has been outstanding for more than 2 years, but I can finally say this is now incorporated in the plugin. You can now set a default country, from the countries you have in your database.
So closing this topic now (finally) :)
from acf-city-selector.
Related Issues (20)
- front end users can't search these cities, states and countries? HOT 1
- No Country or City pr State are showing after importing csv file correctly. HOT 2
- Custom post type archives based on city selector fields HOT 8
- use in elementor or jet engine form HOT 1
- Raw import not working & some city files not available HOT 5
- I see countries but not cities HOT 25
- GB csv full of errors HOT 3
- Canada file - just downloaded - 2 errors HOT 3
- Not returning enough cities HOT 7
- Preview Doesn't Return data HOT 4
- Cities not displaying into select list in custom post type edition HOT 1
- meta query search/filter HOT 3
- Search&Filter HOT 2
- Failure in importing Chinese city names:upload was successful, but filed form showed nothing and preview was blank HOT 15
- South Africa! HOT 2
- India HOT 1
- Small field select2 HOT 6
- Transient bypasses WP localization function HOT 4
- US Countries not working. HOT 3
- Add Armenia Country HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acf-city-selector.