Support

Account

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 🙂