我在wordpress自定义主题模板中使用了以下代码
<p id="news"> <?php echo apply_filters('the_content',$myNews)?></p>;
所需的输出应该是这样的
<p id="news"> Herer goes my news content from $myNewsvariable </p>
但我得到这样的输出
<p id="news"></p>Here goes my news content from $myNewsvariable
请告诉我如何解决这个问题
答案 0 :(得分:1)
the_content
函数默认打印出内容。因此,无需在echo
之前复制apply_filters
。
您也可以将过滤器应用于get_the_content
:
<?php echo apply_filters('get_the_content', $myNews); ?>