• I’m having an issue with the shortcode.
    Here’s what i have in my theme file:

    <?php echo do_shortcode('[geot exclude_country="CA"]' . get_field("details") . '[/geot]'); ?>
    <?php echo do_shortcode('[geot country="CA"]' . get_field("details_cad") . '[/geot]'); ?>

    The issue is that the [/geot] shows up in the front end. I’m assuming the get_field tag is causing the shortcode to end before the actual [/geot]. The issue is I have the two shortcodes and i’m not sure what the best method for doing this is….

    Has anyone else had this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Damian

    (@timersys)

    if you remove the get_field the shortcode works fine? For example using any other string?

    What about doing :

    
    $details = get_field('details');
    <?php echo do_shortcode('[geot exclude_country="CA"]' . $details . '[/geot]'); ?>
    Thread Starter aaronrobb

    (@aaronrobb)

    Damian

    Yes the shortcode works great if its just pure content in it.

    The issue is that i’m trying to pull in a Shopify “Buy Now” button code in that field and part of that is javascript. I’m assuming that is breaking the shortcode. The button code on its own works fine, and with your plugin’s shortcode working good, I’m assuming that it just doesn’t like the script in it.

    I’ve tried the setup you suggest there ($details = get_field) and still breaks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding php within shortcode?’ is closed to new replies.