WordPress 查询帮助
对于 Wordpess,我算是个菜鸟。我最近才开始构建主题,但遇到了困难。我试图使用 wpquery 在我的网站顶部展示 3 篇不同的文章,但由于某种原因它只显示一篇。我将在下面包含我的代码,如果有人可以帮助我找出问题所在,我将非常感激!
Pastebin中包含的代码: http://pastebin.com/1DB7vent
<div class="site_width">
<ul>
<?php
$args = array( 'tag' => 'featured', 'posts_per_page' => '3' );
$recent_posts = wp_get_recent_posts( $args );
?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail('featured', array( 'title' => '' )); ?>
</a>
<label>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</label>
</li>
<?php wp_reset_query(); ?>
</ul>
</div>
我希望“li”再重复两次总共三个。我正在尝试获得与此类似的设置:
<div class="site_width">
<li>
<a href="feat.article1.permalink" title="feat.article1.title">
<img src="feat.article1.featured.image">
</a>
<label>
<a href="feat.article1.permalink" title="feat.article1.title">
"Featured Article 1 Title"
</a>
</label>
</li>
<REPEAT 'LI' ABOVE TWICE MORE BELOW>
</div>
I'm sort of a noob when it comes to Wordpess; I've only recently started building themes and I've run into a wall. I'm trying to feature 3 different articles at the top of my site using wpquery and for some reason it's only displaying one. I'll include my code below and if anyone can help my figure out what's wrong I would be very grateful!
Code included in pastebin: http://pastebin.com/1DB7vent
<div class="site_width">
<ul>
<?php
$args = array( 'tag' => 'featured', 'posts_per_page' => '3' );
$recent_posts = wp_get_recent_posts( $args );
?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="nofollow">
<?php the_post_thumbnail('featured', array( 'title' => '' )); ?>
</a>
<label>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</label>
</li>
<?php wp_reset_query(); ?>
</ul>
</div>
I want the "li" to repeat 2 more times for a total of three. I'm trying to get a setup similar to this:
<div class="site_width">
<li>
<a href="feat.article1.permalink" title="feat.article1.title">
<img src="feat.article1.featured.image">
</a>
<label>
<a href="feat.article1.permalink" title="feat.article1.title">
"Featured Article 1 Title"
</a>
</label>
</li>
<REPEAT 'LI' ABOVE TWICE MORE BELOW>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看当前主题目录中的loop.php。您需要循环查询结果并显示它们。一般结构是这样的:
Take a look in current theme's directory at loop.php. You need to loop through your query results and display them. The general structure is like so: