query_posts 的奇怪问题
我一直在尝试使用查询帖子将 H5 和 H6 标签添加到最近的帖子中,但是 WordPress 不想正确应用它们。它似乎只将它们应用于第一个结果,但在其余的结果上,它只是丢弃列表的第二项。
我将粘贴 sidebar.php 和 style.css 的一些行。我将非常感谢你的帮助。我已经摆弄这个问题三个小时了,但没有运气。
www.estamosobservando.com
sidebar.php
<div id="widget">
<h3>Latest posts</h3>
<?php query_posts('posts_per_page=3'); if (have_posts()) : while (have_posts()) : the_post();?>
<ul>
<li><h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5></li>
<li><h6><?php the_date(); ?></h6></li>
</ul>
<?php endwhile; endif; ?>
style.css
#widget { padding: 133px 0px 0px 20px; text-align:left; }
#widget ul {margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; list-style-type:none; list-style-image: none; text-decoration: none;}
#widget li { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; list-style-type:none; list-style-image: none; text-decoration: none; }
I've been trying to put H5 and H6 tags to the recent posts using query post, but
Wordpress doesn't want to apply them correctly. It seems to apply them only to the first result, but on the rest, it just discards the second item of the list.
I'm going to paste the sidebar.php and some lines of the style.css. I will greatly appreciate your help. I've been fiddling with this for three hours now with no luck.
www.estamosobservando.com
sidebar.php
<div id="widget">
<h3>Latest posts</h3>
<?php query_posts('posts_per_page=3'); if (have_posts()) : while (have_posts()) : the_post();?>
<ul>
<li><h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5></li>
<li><h6><?php the_date(); ?></h6></li>
</ul>
<?php endwhile; endif; ?>
style.css
#widget { padding: 133px 0px 0px 20px; text-align:left; }
#widget ul {margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; list-style-type:none; list-style-image: none; text-decoration: none;}
#widget li { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; list-style-type:none; list-style-image: none; text-decoration: none; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的所有三篇最新帖子均来自今天 5 月 30 日。
来自 WordPress 文档:
或者,您可以屈服于
the_date
的工作方式,并稍微修改您的布局,以有效地将日期作为包含该日期的所有帖子的标题。All three of your latest posts are from today, May 30.
From the WordPress docs:
Alternatively, you could succumb to how
the_date
works, and modify your layout a little to effectively have the date as a heading that encompasses all posts for that date.