我使用Wordpress的条件标签来自定义侧栏中的信息输出 .
我用过这个:
<?php if is_home(); {
echo 'blah blah...'
} else {
echo '<?php $myQuery = new WP_Query(\'showposts=3\');
while ($myQuery->have_posts()) : $myQuery->the_post(); ?>'
<?php endwhile; ?>
} ?>
现在我总是得到“have_posts()):$ myQuery-> the_post();?>”作为我的侧边栏中的文本输出,所以$ myquery部分似乎会导致问题,有人可以帮我找到错误吗?
非常感谢你提前 .
编辑:说明我希望侧边栏在博客索引页面(is_home)上输出其他信息 . 在除博客索引页面之外的所有其他页面上,应显示最后三个帖子 . 这就是我使用WP_Query的原因
1 回答
改为:
一个
echo
(1)用于输出一个字符串,它赢了't execute code. I'建议你查找你在PHP手册中遇到的每个新函数(2)如果你可以't find it there it' s可能是一个WordPress特定的函数,你可以在WordPress Codex(3)http://php.net/manual/en/function.echo.php
http://php.net/manual/en/
http://codex.wordpress.org/Function_Reference/