简体   繁体   中英

PHP Variable within Wordpress shortcode

I need to use a shortcode but insert the variables the customer enters into the shortcode.

I have tried to use the below:

echo do_shortcode('[su_accordion][su_spoiler title="What is your name and your position in       the company?"]'.the_field('whats_your_name_and_your_position_in_the_company').'[/su_spoiler][/su_accordion]');

However it just puts the echo'd text above the accordion shortcode http://prntscr.com/3zzfv9 .

Any ideas?

Thanks!

Found the answer here https://wordpress.stackexchange.com/questions/77384/echo-do-shortcode-with-custom-field-not-working

Need to use get_field as opposed to the_field

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM