Thanks for writing @hube2 🙂
Yeah, i figured that they didn’t add any other validation than native html.
But since the form is created by ACF on the backend, I just wondered if there was any way of changing the output so that I could add my own pattern.
Probably going to make my own js, with setAttribute, to override the element.
Thanks for your update @speakincode! This might actually help me out with my problem as well 🙂
If anyone has this problem – the answer in this post might prevent this from happening (untested in my scenario): Headless WordPress: ACF fields return empty once a post is created with WP-API
Hi!
If you have the ID for the term, you could do this to get the name of the term:
$termName = get_term( $termID )->name;
The function get_term(); returns an object for the term.
Hi!
You can find all the documentation, including code examples, for the Post Object field here: ACF Post Object Field
Glad it worked out, @brosenbaum_tep 🙂
I’ve never needed to activate Geocoding API for ACF maps before, so it might just been som delay? You could check your google console stats to see if you get any hits on Geocoding API 🙂
Ok, so I found a way to save/update a little bit quicker with update_field();.
Basically made a loop with pagination (because getting 2000k++ products is a bit heavy) and fetched the value needed from get_post_meta(); and used update_field(); to save the value correctly.
Here’s my code (got some var_dumps just for testing and such).
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'product', /* product post type */
'posts_per_page' => 99, /* all products */
'paged' => $paged
);
$products = new WP_Query( $args );
// check if products exists
if( $products->have_posts() ) {
?>
<div class="pagination">
<?php
//Pagination
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $products->max_num_pages,
'current' => max( 1, get_query_var( 'paged' ) ),
'format' => '?paged=%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => sprintf( '<i></i> %1$s', __( 'Newer Posts', 'text-domain' ) ),
'next_text' => sprintf( '%1$s <i></i>', __( 'Older Posts', 'text-domain' ) ),
'add_args' => false,
'add_fragment' => '',
) );
?>
</div>
<?php
// loop products
while( $products->have_posts() ): $products->the_post();
$postid = $post->ID;
echo "<li>";
//Get values stored in meta
$sor = get_post_meta($postid, 'prisgruppe_sor_pris', true);
$nord = get_post_meta($postid, 'prisgruppe_nord_pris', true);
//My acf-fields are in a group, so here i make an array for the group subfields
$valuesSor = array(
'pris' => $sor
);
$valuesNord = array(
'pris' => $nord
);
//update fields which are groups
update_field( 'prisgruppe_nord', $valuesNord, $postid );
update_field( 'prisgruppe_sor', $valuesSor, $postid );
//testing things
var_dump(get_field('prisgruppe_sor'));
var_dump($postid);
echo "</li>";
endwhile;
// reset query to default query
wp_reset_postdata();
}
Would still love to hear if anyone have a solution to prevent this mess 😉
Hi!
Make sure you activate both Google Maps Javascript API as well as Places API in the Google Console. The function you are trying to use is using the Places API.
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.