INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

bring back one result then others

bring back one result then others

(OP)
I have designed my front page of the blog to display the latest post full width and the rest in two columns beneath.

What is the best way of coding this up in my theme?

I tried to have two queries, the first using limit to bring back just the first entry to display full width, then another to bring back the rest but I can`t get limit to work. is this the best way or should I be doing it differently i.e. bring back all but only display the first (latest) full width

here is what I am doing at the moment

CODE

<?php query_posts('limit 0,1'); ?>

<?php while (have_posts()) : the_post(); ?>
  
<div id='fullwidth'>
<h1><?php the_title(); ?></h1>
  
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>
  
<?php endwhile; ?>

<?php query_posts('limit 1,9'); ?>

<?php while (have_posts()) : the_post(); ?>
  
<div id='halfwidth'>
<h1><?php the_title(); ?></h1>
  
<?php the_content('Read the rest of this entry &raquo;'); ?>
</div>
  
<?php endwhile; ?>

thanks for any help

RE: bring back one result then others

(OP)
Fixed:

Just a quick update to say I have sorted this. Not sure if this is the best way but it works. I found a page on wordpress highlighting all the options with query_posts and came up with this

CODE

<?php query_posts('posts_per_page=1'); ?>

        <?php while (have_posts()) : the_post(); ?>
  
  <h1><?php the_title(); ?></h1>
  
  <?php the_content('Read the rest of this entry &raquo;'); ?>
  
  <?php endwhile; ?>
  
  
  
  <?php query_posts( array( 'posts_per_page' => 4, 'offset' => 1 ) ); ?>

        <?php while (have_posts()) : the_post(); ?>
  
  <div style='width: 400px; display: inline-block;'>
  <h1><?php the_title(); ?></h1>
  
  <?php the_content('Read the rest of this entry &raquo;'); ?>
  </div>
  
  <?php endwhile; ?>

RE: bring back one result then others

probably not the best way as you hit the database twice.  this means double the work but also may mean that you get post duplication top and bottom if you are unlucky enough to have an entry posted in the intermediacy (unlikely but possible).

the better way would be just to do this

CODE

$first = true;
<?php while (have_posts()) : the_post(); ?>
  <?php if ($first):?>
  <h1><?php the_title(); ?></h1>
  
  <?php the_content('Read the rest of this entry &raquo;'); ?>
  <?php $first = false; ?>
  <?php else: ?>
   
  <div style='width: 400px; display: inline-block;'>
  <h1><?php the_title(); ?></h1>
  
  <?php the_content('Read the rest of this entry &raquo;'); ?>
  </div>
  <?php endif; ?>
  <?php endwhile; ?>

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close