
Hi @rkeefer
Here’s how you would do this based on the code you’ve provided
elseif( get_row_layout() == 'quotes_slider' ):
$heading = get_sub_field('heading');
$quotes = get_sub_field('quotes');
?>
<div class="ctaContent ctaContent1 ctaTestimonials clearfix">
<h3><?php echo $heading; ?></h3>
<div class="flexslider" id="testimonialsSlider1">
<ul class="slides">
<?php foreach($quotes as $quote): ?>
<li>
<?php echo $quote['subfieldname']; ?>
</li>
<?php endforeach; ?>
</ul>
</div><!-- #testimonialsSlider1 -->
</div>
<?php endif; ?>
Good luck!

I’m not sure I understand you. What do you mean by browser image upload?

Hi Gergen,
WordPress in itself have a preview ability for posts and pages.
That’ll show the proper layout without having to actually save the post.
Of course it’s not loaded in a modal iframe directly on the edit screen but it’s pretty nice.

Hi @ngtrian
Embedding a youtube video in WordPress is as simple as just pasting in the link to the video in your editor. There’s also a oembed specific field type in ACF if you want the frontend form to just have a single inputfield specifically for a youtube link (or any other oembed compatible url like twitter, vimeo etc)

Hi @jluc73
The zoom is not saved in the field value. It will only contain lat, lng and address. However you should be able to get the zoom value by fetching the field object get_field_object().
http://www.advancedcustomfields.com/resources/get_field_object/

Hi @lmartins
I don’t think you can do it with field created with the admin interface. However if you register your fields with php: http://www.advancedcustomfields.com/resources/register-fields-via-php/
You could probably wrap the label values in __(‘yourlabel’, ‘yourlangaugelocale’)

Hi,
Please have a look here for how to integrate ACF with WPML:
http://www.advancedcustomfields.com/resources/multilingual-custom-fields/

Hi Greenhoe,
I don’t think you can easily update the taxonomy parameter of your field once the edit screen has been rendered. It would require an AJAX call and recreating the entire field dynamically..
May I suggest a different solution that’s maybe a bit easier and doable.
If you use a relationship field instead there’s a built in filter capability for taxonomies. You can set the field to only allow for 1 value so that it’ll work pretty much the same as the post_object field.
Then if you really want you should be able to create some custom Javascript for the extra functionality. Look for a change in the taxonomy dropdown and change the taxonomy filter dropdown in the relationship field accordingly. It should trigger the filtering automatically. If you also want to make sure the client can’t change the filter themselves you could just add a tiny CSS snippet to hide the taxonomy filter from them.
What do you think?

Hi PandS,
Great that you’ve found the solution yourself. It was exactly what I’d suggest doing.
However you could use acf/input/admin_head to make sure your custom CSS snippet only loads where necessary 🙂
http://www.advancedcustomfields.com/resources/acfinputadmin_head/

Hi ahowell1,
I think an easier hook for you to use would be acf/pre_save_post
http://www.advancedcustomfields.com/resources/acf-pre_save_post/
With it you can check for your field values using $_POST and do a wp_redirect based on the value.
Good luck!

Hi Joe,
Do I understand you correctly if I think you have a larger field group which contains amongst else a repeater field? And the repeater field in term contains multiple fields including a google map field.
I think the easiest way for you to do this would be to create another field group for your CPT. In it you’ll put just a single google maps field. Then set the field_groups parameter of acf_form() to the new group so that a visitor only see this single google maps field.
Then you hook into the save_post action. Make the necessary checks to make sure it’s your CPT and a value has been set to the new google maps field.
Here’s the tricky part. There is no easy way to add a new row programmatically to ACF. There’s only the update_sub_field function which are capable of updating an existing subfield value.
So what you need to do is first fetch the repeater fields value directly from the DB (which is a number corresponding to how many rows there are). Update it with +1 and then you can use update_sub_field.
I’ve done this myself in a project recently and it works 🙂
Here’s some sample code for how to create a new row and add values to it from within functions.php
//Our single google maps field
$temp_map = get_field('field_name');
//Repeater field
$repeater = get_post_meta($post_id, 'field_name', true);
//If there are no rows yet just set to 1, otherwise +1
$new_repeater_count = ( !$repeater ? 1 : $repeater + 1 );
update_post_meta($post_id, 'field_name', $new_repeater_count);
//Now we can start adding our sub field values. However the update_sub_field function takes 0 as base so we actually need to subtract 1 from our $new_repeater_count
$index = $new_repeater_count -1;
//Update the map sun field
update_sub_field( array( 'repeaterfieldkey', $index, 'subfieldkey' ), $temp_map), $post_id );
//And now we want to clear the single google maps field since there shouldn't be any preset address for the next person!
update_field('fieldkey', '', $post_id);
Let me know how that works out!

Thanks @johanhermansson for the snippet, works like a charm.
@wube you’ll need to put this code in the parent themes functions.php and of course make sure you have ACF 5.n pro installed.
I can confirm that above snippet works!

Well if $value is the entire repeater you could do something like this:
// Set the first sock image uploaded as the featured image
function acf_set_featured_image( $value, $post_id, $field ){
if(isset($value) && is_array($value)){
delete_post_thumbnail( $post_id);
//Add the value which is the image ID to the _thumbnail_id meta data for the current post
add_post_meta($post_id, '_thumbnail_id', $value[0][sock_image]);
}
return $value;
}
// acf/update_value/name={$field_name} - filter for a specific field based on it's name
add_filter('acf/update_value/name=sock_images', 'acf_set_featured_image', 10, 3);
That is if you’ve set the return value of the image field to URL. Otherwise you’ll have to do a bit more with it..
But really you should activate wp_debug and do an error_log($value); inside the function to find out what value is first.

Hi,
No problem 🙂 Yes the JSON feature is incredibly useful especially for me as a developer to keep fields in sync between enviroments.
Unfortunately it will not improve performance in your theme where you fetch all the posts and their meta values. The get_field (and similar functions) are all basically wrappers for WordPress own functions such as get_post_meta etc. (they do some more stuff like changing the return value and setting up repeaters etc as well).
The information always have to come from the database.. BUT! There is still stuff you can do.
You can for example in some cases see improvement in performance if you use the get_fields function http://www.advancedcustomfields.com/resources/get_fields/.
Or take it a step further and create your own transients in which you store some values so your visitor don’t have to fetch them dynamically on every page load. https://codex.wordpress.org/Transients_API
And of course caching is important but I’ll assume you have that already!

Hi,
Actually since the user field uses select2 it pretty much has these abilities already I’d say.. You can search for users directly in the field, add multiple users and easily remove them.
It’s pretty much the same as a relationship-field except it looks and behaves a bit different (and of course there’s no taxonomy filtering and stuff like that but that’s obvious why not)

I’ll 1+ this.
Haven’t needed to use the forums too much since I’ve been using ACF for years and frankly can’t find much help here anymore but when I do search for something it’s a nightmare.
In regards to search performance I think using something like Elasticsearch with elasticpress would really be beneficial.

I think your issue is that you have a repeater field with the name of “beelden” but also seem to have a subfield within that repeater with the same name?

Hi,
This is not really what custom fields are for.
I would suggest that instead of using a custom field you can create your own taxonomy (also possible with Custom Post Type UI) which will be the Holiday code.
Then in your permalink-settings make sure you have a custom structure of
/%category%/%postname%/
That’ll lead to the permalink-structure you’re looking for and also let you have archives of holidays within a specific holiday code. Win win.
A bonus is that this permalink-structure is recommended as the best for SEO.

Hi,
With ACF Pro (5) there’s also the possibility to have ACF save the fields to json files which will get loaded instead of loading from the DB (which will speed things up).
http://www.advancedcustomfields.com/resources/local-json/
But to answer your questions
1. Yes you can delete the fields from wp-admin if you put them in a php file but it doesn’t really matter if they remain, ACF will just load them from the php file anyway. You would not loose any data if ACF fields are removed. In deleting fields or fieldgroups you’re not actually deleting anything from posts, terms, user etc. you’re just removing the GUI for working with the meta data. It’ll still be there in the database and you could retrieve them yourself using get_post_meta for example.
2. I haven’t tested too much with the php inclusion but I’m pretty sure it’d be faster. However I’d very much recommend using the JSON method instead since that’ll mean you can still easily add, remove or modify your fields without having to export and paste the new php code everytime.

The short answer is that you can’t order your terms by a custom meta field unless you loop through them and create your own array of objects in that order.
However since you say they each have a number maybe this number is just so you can order them the way you want and nothing else really. If so you can use a plugin like this: https://wordpress.org/plugins/taxonomy-order/
There are also other plugins that do the same thing I just grabbed the first I could find 🙂

That’s because your $value is a repeater field rather than a single image field.
However I’m not sure wether $value will be the entire repeater or just the row count which is actually saved to the database for a repeaterfield.

Hi,
I’m just finding myself in the same situation. (about 1,5 years later.. )
Luckily for me my needs are in the wp admin backend so performance is not crucial.
The only solution I can think of is to fetch all terms, loop through them and check for the value using get_field. Not pretty and wont work when you have thousands of terms but for a smaller amount and in backend it should be fine.

It just hit me that the object output value might be handled by a function that kicks in on get_field etc. so the value saved are probably always just the ID.. So give it a try. Keep the object setting but use just $value.

You can still keep the If statement since it’ll just make sure to only update the value if there is something to update with. Otherwise you’ll end up with no image if you do an update and haven’t set a new image in the form.
Also make sure your field is truly named “post_image”. Or change it to go by the field key which is actually prefered since it’ll retain the functionality even if you change the field name later on.
acf/update_value/key={$field_key}
You can find the field key by heading to screen options (top right) in acf admin and checking show field keys.

To elaborate on Violacase answer.
The _thumbnail_id is the meta_key which the thumbnail ID is being saved with in the wp_postmeta table in your database. It’s being used by default by WordPress.
And if you have the image output set to object you can just use $value->ID and you’re good to go!
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.