Forum Replies Created

  • @hube2 actually I am finding that though it does “load and save” the correct data to the database, it seems as if the post isn’t actually “updated”. Without updating I am not able to use the column filtering in the backend for that field. Only once I actually update the post does then that data become filterable.

  • Answered my own question… Yes it in necessary.

  • I am considering using acf/load_value/key={$field_key} are all the parameters required? So do I still need to loop through each post in the custom post type?

  • Support led me in the right direction – I added a custom validation to that field, works like a charm

    //**********Custom Validation for Taxonomy Field
    add_filter('acf/validate_value/type=taxonomy', 'my_acf_validate_taxonomy', 10, 4);
    function my_acf_validate_taxonomy( $valid, $value, $field, $input ){
    	// bail early if value is already invalid
    	if( !$valid ) {
    		return $valid;
        $terms = get_terms( array(
            'taxonomy' => $field['taxonomy'],
            'hide_empty' => false,
        ) );
    	if( count($terms) > 0 ) {
            if(!$value) {
                $valid = 'Please select a category';
    	// return
    	return $valid;
  • Thanks for the explanation @hube2 – Yeah it is definitely confusing. I have contacted the support team and put in a feature request for this.

    So my scenario is I have the opportunity for a user to select a taxonomy to assign to a post, but only if taxonomies exist for that post type. If taxonomies do exist I need to have them required to select one of them.

    Any direction for this?

  • Okay – got this one more or less solved… Here’s what I have going on:
    1. Add a image selection field
    2. Create a custom meta box with an image with an id of “prodimage”
    3. Use @hube2 script to tie into the change of the image selection field
    4. Use an ajax call from this stackoverflow link: in the change event and then call the update_field in the success as shown
    5. send back the URL of the image to the js json.success and update the image with that new URL

    Here are a few snippets:

    First the edited code from @hube2

    _para_image_change: function(e) {
    				console.log('image file change');
    				newAttachID = jQuery('.acf-field-52ebc2ab15adb input').val();
    				newAttachID = newAttachID.toString();
    					type:   'POST',
    					url:    '',
    					data:   {
    						action: 'hit-bottom',
    						imageID: newAttachID, // your option variable
    						postNumID: postID // your option variable
    					dataType: 'json'
    					}).done(function( json ) {
    						console.log( "Ajax call succeeded, let's see what the response was." );
    						if( json.success ) {
    							console.log("Function executed successfully and returned: "+json.message);
    							//update the image src in the metabox
    						} else if( !json.success ) {
    							console.log( "Function failed and returned: " + json.message );
    					}).fail(function() {
    						console.log( "The Ajax call itself failed." );
    					}).always(function() {
    						console.log( "This message is always displayed, whether the call failed or succeeded." );

    And next the php/ajax handoff:

    add_action( 'wp_ajax_hit-bottom', 'wpse_hit_bottom' );
    add_action( 'wp_ajax_nopriv_hit-bottom', 'wpse_hit_bottom' );
    function wpse_hit_bottom() {
        $imageID = $_POST['imageID'];
    	$postNumID = $_POST['postNumID'];
        if( !isset( $imageID ) || $imageID == '' || !isset( $postNumID ) || $postNumID == ''  ) {
            //insert fallback vars
                        'success' => false,
                        'message' => 'Missing required information.'
    	update_field('field_571a8e724a917', $imageID, $postNumID);
    	$full = wp_get_attachment_image_src($imageID,'full');
    	$fullstring = $full[0];
                    'success' => true,
                    'message' => $fullstring
  • Wow…. what a whirlwind – finally getting somewhere. Your reply here sent me in the right direction.

  • I am trying to do all of this without needing to hit the update button, but it seems like that might not be possible, or at least take a decent amount of time to figure out. I have already done quite a bit of trial and error with not much luck.

  • Here are the steps:
    1. select post to edit
    2. select image field and select image
    3. once selected, on the change event (from your example – thanks!) update a text field with the id of the image
    4. then get this id value via PHP (my code that doesn’t work) so that I can access the URL of the newly selected image.

    You are right I can probably do it all with javascript, just felt like it would be cleaner this way.

    I am no PHP expert so not sure if I can really call a PHP script multiple times or if PHP is really only called once.

  • I am getting somewhere – now what I am struggling with is getting a value via PHP of an acf input field. The $_GET method doesn’t seem to be working, not sure if it is because the name is actually an array element… This is what I am trying to get working –
    <?php update_field('image_selection', $_GET['acf[field_571a8e724a917]']); ?>

    The get should be returning a number.

  • Thanks for the help, I will check out the link to the .js Can I contact you if I have a question or two?

    So far what I have working is an image field loading an image, then in a custom meta box I have a “refresh” button that I can click to load the image into the custom HTML. I am hoping I can do away with the refresh button with what you are sharing.

  • Interesting… I would be interested in taking a look at that JS and seeing what I can get working. I’ll try to post back here with progress, if any 🙂


  • Good suggestion, but I don’t want the entire HTML area to be editable and the HTML content would also need to have some additional JavaScript functionality that I don’t think can be added in with the WYSIWYG field. Make sense?

  • I may be having a similar issue. Have you tried for testing purposes, change the select to radio button? That seemed to be a quick work around for me.

  • @elliot just checking to see if this item got added into the updates yet?

  • Thanks @elliot
    Would be great to know when it is added – I will watch for it!
    Thanks again for such a great plugin and for awesome support – top notch all around!

  • Hi @elliot,
    Yeah that is the issue, but what you mentioned is not true about the WordPress WYSIWYG, if you add an image/file with it it will get attached to the post even if it was in the media library originally.
    Using your WYSIWYG does it correctly as well. Any chance to get that same outcome with the image or file fields?


  • Hi @elliot
    To clarify the issue – and you can go through these steps too –
    – Upload an image/file to the media library
    – create a new post and add that new file to the post using the image field
    – save the post
    – go to the media library and you will see that the file is not “attached” to the post

    The issue is the same for new and existing posts. Hope that helps clarify it a bit more – let me know if you need more info.

  • I checked the “WYSIWIG Editor” ACF, and when using the “Media Upload” button it does more or less what I am needing the File ACF and Image ACF to do, which is add the file as an actual “attachment” to the post.

    Hope this helps with the troubleshooting and finding a possible solution.

  • An option might be when adding an image with the image ACF, adding it as an actual “attachment” to the post as well would be great!

  • Hi Elliot,
    Thanks for getting back to me. Yeah, being able to set a default value to already existing/published posts would be a great addition! Let me know if you get this added or when you open the discussion for it!

    Thanks again!

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