Forum Replies Created

  • Thank you jessepearson, it works great!

    @ACF Team: any chance a function/action like this can get into the plugin? It is very useful for automatic site deployment, especially in multisite installations.

  • I have the same problem but on flexible layouts fields.

    i would like to make some customized css for different layouts of the same repeater.

    I ended up adding some jquery to get the data-layout attribute from repeater layout row and using it as css class to the very same element.
    So you’ll have different classes for different repeater layouts, based on the layout name.

    this is the small script I’ve done, nothing special but it works.

        "use strict";
         $(document).ready(function() {
            var layouts = $('.acf-flexible-content .layout');
            layouts.each(function( key, value ) {
                    var section_attribute = $(this).attr('data-layout');

    Would be surely better if this classes were built in ACF PRO

  • problem Solved here

    acf.screen is an old method, now we must use: acf.ajax.update

  • Thanks to Eliot supporto i solved.
    Correct way to reference to acf js is

    acf.ajax.update( 'cpt', jQuery(this).val() ).fetch();

    I made a github fork of the lukechapman plugin, tu be used for Single Post Template plugin instead of Custom Post Template plugin

  • Quite same issue here,
    I’ve expained here better:

    I’m using ACF PRO

    Maybe the object acf.screen does not more exist or has changed name, or it’s different in PRO version?

    Would really like to have an answer on this.

    PS: Is there any documentation about acf.screen stuff?

  • Hi charis,
    I’m trying to use the plugin along with Single Post Template, I made some few steps, but I’ve got a js error.

    This is what I’ve done:

    In the main plugin file:

    1) I changed all “Template Name Posts” to “Single Post Template” (there are a few)

    2) I changed the jquery selector to match the Single Post Template dropdown id: #post_template (instead of #custom_post_template as in CPT plugin)

    I have post templates in dropdown,
    but when I switch template, I have this js error:

    TypeError: acf.screen is undefined

    PS: I’m using ACF PRO 3.7.4

  • OK, this is far too complicated for the time window I have.

    Maybe is possible to pre-populate fields? Like precheck the field that fires the condition?

  • I tried to use the add_action filter I was already using in the first version, but without the do_actino in the acf/pre_save_post filter.

    It looks like it works, but I’m still using

    add_post_meta( $post_id, '_thumbnail_id', $image );

    instead of yours

    set_post_thumbnail($post, $attachment_id);

    do you suggest to use the second one?

  • John You’re awesome.

    I think the key is putting the ‘acf/pre_save_post’ filter before:


    but I still have 1 issue: featured image is not saving.

    maybe the ‘acf/save_post’ action is needed fo this like I saw in that article I linked before?

  • 1) no other filter, just frontend templates

    2) As you can see I use 2 field groups in the acf_form. The first one is made just for frontend form (is where I have post title, content and featured image), the second one (where I have the issue) is the very same I use in backend.

    3) IN the 2nd field group I have 6 fields, in this order:
    – true/false field (true is the condition for all the following fields to show) – working
    – wysiwyg field – working
    – flexible content field (inside there are 4 layouts, with a total of 11 subfields) – not working
    – flexible content field (inside there are 2 layouts with a total of 5 subfields) – Not working
    – flexible content field (inside there are 2 layouts with a total of 3 subfields) – Not working
    – wysiwyg field – working

    If you want to try, I’ve exported both groups in this zip file

    PS: I’ve tried not to use the second group (the complex one) and using another one just with 1 repeater field with only one text subfield, same problem: data is sent from the form, rows are created in backend but values are empty, infact in database I can see serialized strings like this one: a:2:{i:0;s:1:”A”;i:1;s:1:”A”;}

  • I tried like you suggest.

    add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post' );
    function tsm_do_pre_save_post( $post_id ) {
    	// Bail if not logged in or not able to post
    	if ( ! ( can_user_post_recipe() ) ) {
    		return $post_id;
    	// check if this is to be a new post
    	if( $post_id != 'new' ) {
    		return $post_id;
    	// Create a new post
    	$post = array(
    		'post_type'     => 'post', 
    		'post_status'   => 'pending', 
    		'post_title'    => wp_strip_all_tags($_POST['acf']['field_559a8e6366915']), // Post Title ACF field key
    		'post_content'  => $_POST['acf']['field_559a8e7b66916'], // Post Content ACF field key
    	$post_id = wp_insert_post( $post );
    	wp_set_object_terms($post_id, array(1829), 'category');
    	// ACF image field key
    	$image = $_POST['acf']['field_559a8eb766918'];
    	// Bail if image field is empty
    	if ( empty($image) ) {
    		return $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', $image );
    	return $post_id;

    Now the wp_set_object_terms seems to work nicely, but the thumbnail is not saved at all, and the original issue is still there: no repeater or flexible field saved in db.

    Maybe I did not say this: in backend everything is working fine (since a lot of time)

    I can’t see any error, not js in console, not php in server log.

  • Actually I tried to follow this article:

    anyway I keep having the same issue even removing that line.

    Lately I tried also assign to the post a category in the pre_save_post, adding this line
    wp_set_object_terms($post_id, array(1829), ‘category’);

    right after
    add_post_meta( $post_id, ‘_thumbnail_id’, $image );

    but it works randomly, sometimes the category is assigned, sometime not.

    I’ve also moved all the code (except the acf_form part) from page template to theme funcions.php, but nothing’s changed.

    Problem is I need this to work asap, after losing 2 days on this I’m ready to pay someone to fix it. Anyone available?

  • Further update.

    debugging the form data with chrome dev tools, it looks like the values are sent, but for some reason they are not saved in db

    here it is the admin-ajax.php form data sent in headers

    acf[field_559a8e6366915]:This is the post title
    acf[field_559a8e7b66916]:this is the post content
    acf[field_5383505f17035]:this is another wysiwyg field
    acf[field_536954f9e3362][559fe5d5e1e5d][field_5369588b92009]:pur sugar in water
    acf[field_536954f9e3362][559fe5dce1e5e][field_5369588b92009]:mix a lot and drink
    acf[field_53695a0dcfde2]:this is yet another wysiwyg field

    PS: what is “acfcloneindex”?

  • New update:

    I tried using a more simple field group, containing just
    – a repeter field of text fields
    – a flexible content field with 2 fields: text and image

    for both I have the same issue: fields are created in database, infact I see rows in backend edit post, but this rows do not have any value inside. they are just empty.

  • I have an update, looking in db, I can see that the repeater fields are saved, but they are just empty, this is a screenshot:

    In screenshot, the repeater field is “recipe_details”, this field contains severao flexible layout fields, that are not saved, infact the metavalus is just an empty serialized string -> a:2:{i:0;s:1:”A”;i:1;s:1:”A”;}

    I really can’t save this flexible fields contained in repeater field.
    Nobody has already did that?

  • Hello Elliot,
    in your tutorial you say to transalte Field Groups and do nothing on Fields.
    But in the WPML options I can’t find any “fields” option, just Fields Groups.

    Maybe this happens because I’m using the WPML Translation Management addon to use icanlocalize professional translations.

    I’ve also marked as “translate” all the custom fields as you say in the part “avoid data loss”.

    When I send to professional translators this contents, they are able to translate all the fields, and I get this fields translated in the WPML translations editor interface (screenshot:

    But If I open the post normally, in the standard WP edit interface, fields are not there (screenshot:

    I understand that this is also a WPML issue and that they should help as well, but unfortunately any request about ACF in WPML forum is answered with this sentence “ACF is not in our compatibility list, you should use Types instead of ACF”…

    Is there someone able to make repeater and flexible fields translatable by icanlocalize professionals?

  • You’re surely right foxviewr, I already tested regressing to previous WPML version and reported the issue to WPML suppor forum (where I found huge amount of people in similar situation).

    I just felt that was good to report this issue here too, for some reason even with the buggy last version of WPML, if I use ACF 4.4.0 with repeater and flexible content addons, instead of ACF Pro, everything looks fine.

  • It seems that the last version of WPML is causing this issue. There are a huge amount of support request on WPML forum after last update. They say to be aware about this and that they will fix the issue asap, maybe today. I really hope it’s not an ACF fault, I’m deeply in love with this plugin 🙂

  • Many Many thanks thisislawatts!
    your hack worked as a charm.

    I’m a big fan of ACF, but this is quite disappointing. I did not have any asnwer from official support, not even a notice about the missing db upgrade.

  • Sorry to bump this, but I can’t figure out how to fix this.

Viewing 22 posts - 1 through 22 (of 22 total)