Search code examples
phpwordpressshortcode

Using PHP inside a shortcode inside PHP... syntax issue


Ok, I'm OK with PHP but not an expert. What's the correct syntax here?

I'm trying to pull in an Advanced Custom Field data INSIDE some PHP, which is INSIDE a shortcode.

I have an ACF field called: the_sub_field("google_doc_key")

<div><?php echo do_shortcode("[gdoc key='https://docs.google.com/spreadsheets/d/"'. the_sub_field("google_doc_key") .'"/edit' gid='0']"); ?></div>

Somethings not right here... any help is appreciated.


Solution

  • <div><?php echo do_shortcode("[gdoc key='https://docs.google.com/spreadsheets/d/'". the_sub_field("google_doc_key") ."'/edit' gid='0']"); ?></div>
    

    Try that, you had the ' and " mixed up just before the_sub_field