Support

Account

Home Forums Backend Issues (wp-admin) Retrieve post_ID in divi theme visual builder Reply To: Retrieve post_ID in divi theme visual builder

  • What you are going to have to do is build your own shortcode https://codex.wordpress.org/Shortcode_API

    The reason why is that ACF depends on get_the_ID() when one is not supplied.

    Here is the built in ACF shortcode modified to work with the code you provided.

    
    
    function my_acf_shortcode( $atts ) {
    	
    	// extract attributs
    	extract( shortcode_atts( array(
    		'field'			=> '',
    		'post_id'		=> false,
    		'format_value'	=> true
    	), $atts ) );
    	
    	if (!$post_id && isset( $_POST['et_post_id'] )) {
    	  $post_id = $_POST['et_post_id'] ;
    	}
    	
    	// get value and return it
    	$value = get_field( $field, $post_id, $format_value );
    	
    	
    	// array
    	if( is_array($value) ) {
    		
    		$value = @implode( ', ', $value );
    		
    	}
    	
    	
    	// return
    	return $value;
    	
    }
    
    add_shortcode('my_acf', 'my_acf_shortcode');