vSlider - 在 WordPress 中,我使用常见问题解答中提供的功能:
<?php if(function_exists('vslider')){ vslider('vslider_options'); } ?>
我正在努力做到这一点。所以它知道以 post-ID 作为它的名字。但它不起作用。
<?php if(function_exists('vslider')){ vslider('<?php the_ID(); ?>'); } ?>
vSlider - 在 WordPress 中,我使用常见问题解答中提供的功能:
<?php if(function_exists('vslider')){ vslider('vslider_options'); } ?>
我正在努力做到这一点。所以它知道以 post-ID 作为它的名字。但它不起作用。
<?php if(function_exists('vslider')){ vslider('<?php the_ID(); ?>'); } ?>
您不能嵌套<?php ?>
在已经打开的<?php ?>
. 这是不受支持且在语法上无效的。只需在适当的位置调用该函数。
显然,the_ID()
是那些在不返回其值的情况下打印到输出缓冲区的 Wordpress 函数之一。要在函数中有用的地方获取返回的 id ,请get_the_ID()
改用。
<?php if(function_exists('vslider')){ vslider(get_the_ID()); } ?>
当表示为正确缩进的代码时,语法问题变得更加明显。
<?php
if (function_exists('vslider')){
vslider(get_the_ID());
}
?>
是的,您可以通过删除 php 标签来做到这一点
<?php if(function_exists('vslider')){ vslider('<?php the_ID(); ?>'); } ?>
should be
<?php if(function_exists('vslider')){ vslider(the_ID()); } ?>
你的the_ID()
函数应该在最后返回一个字符串