WordPress的PHP回声问题
问题描述:
我试图用wordpress使用strip_tags()过滤掉所有帖子里面的所有标签。我这样设置:WordPress的PHP回声问题
<?php
// The Query
echo date ("Y");
query_posts('p=10');
// The Loop
while (have_posts()) : the_post();
$footertext = the_content();
echo strip_tags($footertext);
endwhile;
// Reset Query
?>
这似乎并没有去掉他们想要的标签。
答
变化the_content()
变为get_the_content()
。
the_content()
用于直接输出内容,而get_the_content
返回要存储在变量中的内容以供进一步处理。
$footertext = get_the_content();
+0
我可以在循环中使用它吗? – Thomas 2011-05-16 05:37:03
+0
@Thomas:是的,你可以试试。 – 2011-05-16 05:38:40
你以什么方式期待? – alex 2011-05-16 05:31:29