Support

Account

Forum Replies Created

  • I’m using @dsouzaj86 approach for an accordion. Does anyone know how to get the parent group block ID from within the child block?

    Looking for something like:

    <div id="accordion-<?php echo $block[id]"; ?> data-parent="<?php echo $parentblock[id]; ?>">
         Accordion content
    </div>
  • @bronson That solved it for me too. Thank you! This happened to me using the most recent version of ACF in 2021. Don’t know what causes this weird hiccup.

    In case this helps someone else: it was happening to me only on certain field groups inside a flexible content field group. But you have to duplicate the whole flex content group and delete the old one. It won’t work if you just delete the fields inside the flex content field.

  • Hi James, thank you. Do you know why this would only affect the multiple select field, though? It did not require me to save the post to create the field references for any of the standard text fields, date fields or single-select fields that I imported via the same method.

    Thanks!

  • Just checking back in on this to say that this still happens with other form plugin shortcodes as well (Mailpoet, Formidable), and only when used in an ACF wysiwyg field. It seems the issue is that BR tags are added below each hidden field in the form, thus creating a bunch of empty lines above and below the form. Again, this does not happen in the native WP editor — only ACF. This happens with any theme I try. Has anyone had any success with fixing this problem?

  • Ok, I don’t know how to explain it, but I guess my field got corrupted? I created a new image field with same settings, deleted the old field, and it worked. False alarm!

  • I also just tried returning the field as simply the URL (not an array or ID) and the issue exists there as well.

  • John, do you have any other ideas on this issue? I used to use Formidable forms, but my client has switched to Gravity for all their sites now, and this issue is wreaking havoc on layouts since so many of the forms are in ACF WYSWIG editor fields.

    Thank you for any insight!

  • Same problem here. It doesn’t work if I try getitng the unformatted value and applying the filters as John suggested above.

    The gravity forms shortcode works fine in the main editor, but not in my ACF wysiwyg editor.

  • Webtech, you should just have to change the post type to “product” or whatever woocommerce’s product post type is named.

    $args = array(
    	'post_type' => array('product'), // post types you want to check
    	'posts_per_page' => -1 
    );
  • Hello. I need to do the same as the OP. And I need to do it without editing each post. There are 364 of them. How can I update the two entries in the postmeta table automatically? Or could I use a database field mapping plugin or import plugin that would do such a thing?

    Thanks for any insight!

  • I am having the same problem, and I’m using the most recent version of ACF.

  • Just wanted to add that wstaley’s solution worked great for me, but you need to change his greater-than symbol to less-than. I also am not using the time of day, only the date, for expiration, so I changed time() to date().

    Here is my working code:

    // expire offer posts on date field.
    if (!wp_next_scheduled('expire_posts')){
      wp_schedule_event(time(), 'twicedaily', 'expire_posts'); // this can be hourly, twicedaily, or daily
    }
    
    add_action('expire_posts', 'expire_posts_function');
    
    function expire_posts_function() {
    	$today = date('Ymd');
    	$args = array(
    		'post_type' => array('offer'), // post types you want to check
    		'posts_per_page' => -1 
    	);
    	$posts = get_posts($args);
    	foreach($posts as $p){
    		$expiredate = get_field('valid_end_date', $p->ID, false, false); // get the raw date from the db
    		if ($expiredate) {
    			if($expiredate < $today){
    				$postdata = array(
    					'ID' => $p->ID,
    					'post_status' => 'draft'
    				);
    				wp_update_post($postdata);
    			}
    		}
    	}
    }
  • @James – THANK YOU! I wrestled with this issue for hours, until I finally found your post.

    I used to have an ACF select2 event that worked prior to ACF 5.4+:

    $("#acf-field_1234567890").on("change", function() { }

    In your answer you mentioned that the selector is actually #acf-field_1234567890-input. That solved it for me. I guess at some point ACF changed the select2 wrapper or version? At any rate, thank you! Your code above solved it for me.

  • I had the same problem, so just adding this here in case it helps someone else:

    I realized I’d used “post taxonomy” instead of “taxonomy term” in the field settings. “Post Taxonomy” puts the fields on the post page if the post been assigned to that taxonomy. “Taxonomy Term” is what puts it on the actual taxonomy editing page.

  • Did you ever solve this?

    I’m having a related but slightly different issue. I’m using ACF in conjunction with the Events Manager plugin. If a user forgets to fill out one of the required Event fields, it prompts an error. When that happens, all of my ACF fields clear. It’s only the ACF fields — other fields are fine. It also only happens with ACF Pro, but not with ACF 4.x. The issue happens even with all other plugins deactivated and using the default WP theme.

  • However — it brings me to a new question. Is this super resource intensive? This contact_person field that I’m populating is present on a LOT of posts.

  • Nevermind! I figured it out myself. I needed to format it like this:

    function my_acf_load_field( $field ) {
    		
         $address = get_field('center_address', 342);
    		
         $field['default_value'] = $address;
         return $field;
    		 
    }
    
    add_filter('acf/load_field/name=contact_person', 'my_acf_load_field');
  • Nevermind. I answered my own question. I needed to get rid of “use” and format it like so:

    function my_acf_load_field( $field ) {
    		
         $address = get_field('center_address', 342);
    		
         $field['default_value'] = $address;
         return $field;
    		 
    }
    
    add_filter('acf/load_field/name=contact_person', 'my_acf_load_field');
  • @commandz – Any chance you’re still checking this? (Or anyone else who understands it?) I am trying to do this very thing, but I need to populate the default value with the value of another ACF field from a specific page.

    Here’s how I tried to implement it in functions.php, but it’s not working:

    
    $address = get_field('center_address', 342);
    	
    add_filter('acf/load_field/name=contact_info',
         function($field) use ($address) {           
    	     $field['default_value'] = $address;
    	     return $field;
         }
    );

    I’m trying to populate the value of field “contact_info” with the value from “center_address”, from post 342. I’m trying to do this on a backend form on the post editing screen, not a frontend form.

    I’m using ACF Pro. The center_address and contact_person field are text fields.

    THANK YOU!

  • Does this still work with ACF Pro? I can’t seem to get it to work and I need to do the same thing!

  • Anyone ever figure this out? I need to do the same thing!

  • +1

    I would LOVE this feature! I have a page with a ton of field groups, which makes for a very intimidating user experience. I’d prefer that the meta boxes start collapsed, so they can choose to expand the boxes they wish to edit.

    [update]

    In case anyone stumbles across this, I found an interim solution using javascript. Install this plugin: http://wordpress.org/plugins/add-admin-javascript/

    And then, on the plugin settings page, in the “JQuery” box, paste this code:

    
    $('.acf_postbox').addClass('closed');
    

    You may want to edit the .acf_postbox to be more specific, but this will collapse ALL acf meta boxes on page load.

  • Or is this something I would be better off using something like Gravity Forms or Formidable Pro for?

  • I solved it. I just needed to use this:

    echo( basename(get_permalink()) );
    
    

    instead of get_permalink().

  • Does anyone know how I would apply this to breaking a nested repeater after the SECOND result?

Viewing 25 posts - 1 through 25 (of 27 total)