query posts
-
How cand I do like this?
http://i45.tinypic.com/xkpuz4.jpg (demo image)
Viewing 5 replies - 1 through 5 (of 5 total)
-
give this a go.
<?php $posts=query_posts($query_string . '&posts_per_page=2'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> </div> <?php endwhile; ?> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> <!-- end first 2 --> <div class="bottomHolder"> <?php $posts=query_posts($query_string . '&posts_per_page=2&offset=2'); ?> <?php while (have_posts()) : the_post(); ?> <?php if($post == $posts[0]) { echo "<div class='bottomLeft' id="post-<?php the_ID(); ?>">"; } else { echo "<div class='bottomRight' id="post-<?php the_ID(); ?>">"; } ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> </div> <?php endwhile; ?> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <!-- end second 2 -->
and some CSS to make them look right
<style type="text/css"> .bottomHolder { clear: both; } .bottomLeft { float: left; width: 280px; } .bottomRight { float: right; width: 280px; } </style>
it should take the first two most recent posts show the excerpt at full width. Then show the #3 and #4 most recent in the 2 column layout like in the pic.
Parse error: parse error, expecting
','' or
‘;” in E:\Web\Localhost\xampp\htdocs\wp-content\themes\loosun\index.php on line 24How can solve this error? 🙂
yeah oops, try this instead:
<?php $posts=query_posts($query_string . '&posts_per_page=2'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> </div> <?php endwhile; ?> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> <!-- end first 2 --> <div class="bottomHolder"> <?php $posts=query_posts($query_string . '&posts_per_page=2&offset=2'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php if($post == $posts[0]) { ?> <div class="bottomLeft" id="post-<?php the_ID(); ?>"> <?php } else { ?> <div class="bottomRight" id="post-<?php the_ID(); ?>"> <?php } ?> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> </div> <?php endwhile; ?> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <!-- end second 2 -->
Works. Thank you!
How can I add another 2 posts, in bottom?
repeat the ‘bottomholder’ code and then adjust the numbers to show and the offset.
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘query posts’ is closed to new replies.