我正在使用WordPress插件来输出取决于国家/地区代码的php包含,我已经设置了根据位置输出文本的条件简码,但无法将其提升到一个新的水平以包含PHP文件:
<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . 'hello' .'[/wpgc_is_country_code]');?>
这会输出"hello",但我希望它包含一个 PHP 文件。 我试过这个:
<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . 'include('include/UK.php')' .'[/wpgc_is_country_code]');?>
但它不起作用,输出是空白的,我在事物的"包含"部分哪里出错了?(我也尝试使用"get_template_part"功能,但没有运气)
提前感谢!
hello 是一个字符串,所以必须有引号,但包含是一个函数,在引号中有任何函数都是错误的。删除include()
上的单引号,然后尝试此操作
<? echo do_shortcode('[wpgc_is_country_code country_code="UK"]' . include('include/UK.php') .'[/wpgc_is_country_code]');?>