简体   繁体   中英

php include in wordpress template shortcodes

i'm working with a wordpress plugin to output a php include that depends on the country code, i've set up the conditional shortcodes that output text dependant on location, but can't take that to the next level to include a php file:

<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . 'hello' .'[/wpgc_is_country_code]');?>

this outputs "hello", but i'd like it to inlcude a php file. i've tried this:

<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . 'include('include/UK.php')' .'[/wpgc_is_country_code]');?>

but its not working, the output is blank, where am i going wrong in the "include" portion of things? (i've also tried using the "get_template_part" function with no luck)

thanks in advance!

你好是一个字符串,所以必须有引号,但是include是一个函数,在引号中有任何函数是错误的。.在include()上删除单引号,然后尝试这个

<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . include('include/UK.php') .'[/wpgc_is_country_code]');?>

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