Home › Forums › Backend Issues (wp-admin) › acf/save_post Shortcodes › Reply To: acf/save_post Shortcodes
Hi @rgdesign
Then I think you need to check if the template is called from the acf/save_post
hook or not.
What I have in my mind is that I think you can use the global $_POST
variable to check if there’s a posted data or not, which mean that the template is called from a saving process or it just included from another template. Maybe something like this:
<?php
// Check posted data
if( isset($_POST['acf']['field_1234567890abc']) ){
$the_shortcode = '[shortcode]';
} else {
$the_shortcode = do_shortcode('[shortcode]');
}
?>
The shortcode: <? echo $the_shortcode; ?>
Where ‘field_1234567890abc’ is the field key that is posted.
If that doesn’t work, I then you need to pass a variable to the template instead. This page should give you more idea about it: http://keithdevon.com/passing-variables-to-get_template_part-in-wordpress/.
I hope this helps 🙂
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.