Support

Account

Forum Replies Created

  • Hi there. So far this is my idea. I will use a post object for my mall. So what i want to do is reuse the code and try to check if my post object with id field_576bd813ca393
    to use this jscript:

    `jQuery(document).ready(function($) {

    $( ‘#acf-field_576bd813ca393’ ).change(function () {

    var selected_mall = ”; // Selected value

    // Get selected value
    $( ‘#acf-field_576bd813ca393 option:selected’ ).each(function() {
    selected_mall += $( this ).text();

    });

    }).change();
    });`

    and this code on my functions.php:

    
    function acf_admin_enqueue( $hook ) {
    	 
      $type = get_post_type(); // Check current post type
      $types = array( 'post' ); // Allowed post types
     
      if( !in_array( $type, $types ) )
    	  return; // Only applies to post types in array
      
      wp_enqueue_script( 'populate-area', get_stylesheet_directory_uri().'/autopopulate.js' ); // '/assets/js/
     
      wp_localize_script( 'populate-area', 'pa_vars', array(
    		'pa_nonce' => wp_create_nonce( 'pa_nonce' ), // Create nonce which we later will use to verify AJAX request
    	  )
      );
    }
    	 
    		add_action( 'admin_enqueue_scripts', 'acf_admin_enqueue' );

    but my problems are the ff:

    1.) i tried using console.log and document.write to try to log the value of selected_mall but i cant seem to make it display on my console and admin page.

    2.) inside $( ‘#acf-field_576bd813ca393’ ).change(function (), how can i check all the cinemas i had also placed from a previous acf custom field? i know i need to use wp_query right and loop through all data. but if i am to use a post object which has both id and value how can i do it?

  • Thank you JAmes, ill try it but i have one more question. How can i call a particular field id from inside the functions.php? we can set the function to a field id by using something like add_filter(‘acf/load_field/key=field_52b1b7007bfa4’ to add that field to the function inside functions.php but what should i do if i want to call a particular field inside one of my function in function.php?

  • Thank you. But can you point me in the right direction on how i can use relationship field to link them?

    I already setup my cinema fields which has mall as one of its fields. What i need now is how i can call the cinema’s linked inside the particular mall in my admin menu. I already know how to use wp_query but setting up the fields in admin is quite confusing.

    cinema setup field

    movie setup field

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