开发者

Wordpress: query_posts - how to show multiple posts

开发者 https://www.devze.com 2023-02-18 15:54 出处:网络
I\'m building a custom WP theme (based on Chris Coyier\'s tutorial at lynda.com) that displays a snip of the most recent blog post on the home page (the blog itself is not the homepage of the site). I

I'm building a custom WP theme (based on Chris Coyier's tutorial at lynda.com) that displays a snip of the most recent blog post on the home page (the blog itself is not the homepage of the site). I'm currently showing just one post, but would like to have the option to show two or more posts. Here's the current code:

   <?php query_posts("posts_per_page=1"); the_post(); ?>
   <div class="date_home">Posted <?php the_time('F jS, Y') ?></div>
   <h3><a href="<?php the_permalink(); ?开发者_JAVA技巧>"><?php the_title(); ?></a></h3>
   <?php the_content('Continue Reading &#8594;'); ?>

I would have thought that changing

posts_per_page=1

to

posts_per_page=2

would do the the trick, but it's not working.

Any help appreciated. Thanks!


Need to replace:
<?php query_posts("posts_per_page=1"); the_post(); ?>
with:
<?php query_posts('posts_per_page=5'); if (have_posts()) : while (have_posts()) : the_post();?>

Complete Code below:

<?php query_posts('posts_per_page=5');  
if (have_posts()) : while (have_posts()) : the_post();?>
<div class="date_home">Posted <?php the_time('F jS, Y') ?></div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_content('Continue Reading &#8594;'); ?>
<?php endwhile; endif; wp_reset_query();?>
0

精彩评论

暂无评论...
验证码 换一张
取 消