• Hello, guys im looking for help.
    Leet say i have posted 10 posts and i need that first post would have different style then counts posts till 4 and set another style to posts. Then resets and do same think till next page.
    <div class=’posts-first’>content</div>
    <div class=’posts’>content</div>
    <div class=’posts’>content</div>
    <div class=’posts-last’>content</div>
    then resets and do
    <div class=’posts-first’>content</div>
    <div class=’posts’>content</div>
    <div class=’posts’>content</div>
    <div class=’posts-last’>content</div>

    <?php get_header();  ?><?php
    /*
    Template Name: Blog of joeybottle
    */
    $pagenum = $wp_query->query_vars;
    $pagenum = $pagenum['paged'];
    
    if (empty($pagenum)) {
    $pagenum = 1;
    }
    
    query_posts("paged=$pagenum");
    ?>
    
    <?php get_header();?>
    
    <?php if (have_posts()) :$count = 0; ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="<?php if($counter==0) { echo 'first'; $counter++; } ?> post">
    
    <a href="<?php the_permalink() ?>"><?php the_title() ?></a>
    
    </div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'joeybottle')) ?></div>
    <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'joeybottle')) ?></div>
    </div>
    
    <?php endif; ?>
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • Try changing this:

    <?php while (have_posts()) : the_post(); ?>
    
    <div class="<?php if($counter==0) { echo 'first'; $counter++; } ?> post">

    to this:

    <?php while (have_posts()) : the_post();
    $class = ($counter++ == 0) ? 'first-post' : (($counter > 3) ? 'last-post' : 'post');
    
    <div class="<?php echo $class; ?>">
Viewing 1 replies (of 1 total)

The topic ‘Different posts styles’ is closed to new replies.