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');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.