Forums

[resolved] style the second page of posts differently (3 posts)

  1. gmisen
    Member
    Posted 3 years ago #

    I'm sure there's a simple explanation for this, but I've searched and can't find anything, can't figure out how to word it properly.

    In my index.php template I style the first post differently than the other nine -- which is cool.

    But when you click "older posts" at the bottom of the page it shows the next 10 posts, but its still formatting the first post on that page differently.

    The only post I want styled differently is the most recent one. Do I need another template for displaying the older posts?

    Which template controls older posts?

    I tried using a home.php template, hoping only the first page would pick it up then the rest would use index.php....but no, they all use home.php now.

    It doesn't seem to be archive or archives either.

    How do I do this?
    Thanks for any help!!

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    <?php
    $paged = (get_query_var('paged'));
    if $paged < 2 {
    //handle posts on first 'page' of posts
    }
    ?>

  3. gmisen
    Member
    Posted 3 years ago #

    sweet!
    thanks alot! $paged, ill remember that

    here's what i ended up with, to put a box around my very first post and the rest styled normally:

    <?php get_header(); ?>
    
    <div id="bigcolumn">
    
    <?php if ( $paged >= 2) { ?>
    
         <div id="navigation"><div class="alignleft"><?php next_posts_link('Older Posts') ?></div>
         <div class="alignright"><?php previous_posts_link('Newer Posts') ?></div>
         </div><div class="clear"></div>
    
    <?php } ?>
    
    <?php $postnum = 0; if (have_posts()) : ?>
    
    <?php while (have_posts()) : $postnum = $postnum + 1; the_post(); ?>
    
    <?php if ( $paged < 2&amp;&amp;$postnum == 1 ) { ?>
    
    <div class="firstpost" id="post-<?php the_ID(); ?>">
    //Boxy first post stuff
    </div>
    
    <div><span class="navigationbtm">recent posts</span></div>
    <div id="navigation"><div class="alignleft"><?php next_posts_link('Older Posts') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Posts') ?></div></div><div class="clear"></div>
    
    <?php } ?>
    
    <?php if ($postnum >= 2 ) { ?>
    
    <div class="post" id="post-<?php the_ID(); ?>">
    //Normal Post Stuff
    <?php the_content('Read more...'); ?>
    </div>
    
    <?php } ?>
    
    <?php endwhile; ?>
    
    <div id="navigationbtm"><span class="navigationbtm"><div class="alignleft"><?php next_posts_link('<span class="blue"><</span> Older Posts') ?></div><div class="alignright"><?php previous_posts_link('Newer Posts <span class="blue">></span>') ?></div></span></div>
    
    <?php else : ?>
    
    <p><span class="posttitle">Not Found</span><br />
    Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    <?php endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic