【问题标题】:Help with Wordpress Query帮助 Wordpress 查询
【发布时间】:2011-08-15 10:52:43
【问题描述】:

说到 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”再重复 2 次,总共重复 3 次。我正在尝试进行类似的设置:

 <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>

【问题讨论】:

标签: wordpress function loops themes


【解决方案1】:

查看当前主题的目录 loop.php。您需要遍历查询结果并显示它们。大体结构是这样的:

<?php while ( have_posts() ) : the_post(); ?>
    <li>
       <?php //show your post  ?>
    </li>
<?php endwhile; // End the loop. Whew. ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 2011-07-19
    • 2011-04-28
    • 2011-02-01
    • 2010-12-24
    相关资源
    最近更新 更多