0

I want to style the latest post differently than all the other posts in a category on a custom page. So far I have this code below which does exactly that:

<?php if (have_posts()) : ?>
 <?php query_posts("cat=4&showposts=1"); ?>
  <?php while (have_posts()) : the_post(); ?>

(Style1)<?php the_title(); ?></br>

  <?php endwhile; ?>
 <?php query_posts("cat=4&showposts=4&offset=1"); // show 4 latests posts excluding the latest ?>
  <?php while (have_posts()) : the_post(); ?>

(Style2)<?php the_title(); ?><br/>

 <?php endwhile; ?>
<?php else: ?>
No Posts Found
<?php endif; ?>

<div class="navigation">
<div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
<div class="alignright"><?php next_posts_link('Next &raquo;') ?></div>
</div>

My question is, how would I then get the pagination to work correctly? Right now clicking Next/Previous loads a different page, but the posts stay the same.

I would like to be able to click Previous or Next, and it only load the style2 posts. Style 1 post would only show when on the front page of the custom page

0
function dot1_get_nav(){
    if ( get_next_posts_link() || get_previous_posts_link() ) { ?>
        <nav class="dot1-navigation clearfix">
            <?php if ( get_next_posts_link() ) { ?>
                <div class="alignleft">
                    <?php next_posts_link( __( '&larr; Older Entries', 'dot1' ) ); ?>
                </div>
            <?php } ?>
            <?php if ( get_previous_posts_link() ) { ?>
                <div class="alignright">
                    <?php previous_posts_link( __( 'Newer Entries &rarr;', 'dot1' ) ); ?>
                </div>
            <?php } ?>
        </nav><?php
    }
}

<?php 
    $post_data_args = array(
        'cat'   => 4,
        'showposts' => 1
    );
    query_posts( $post_data_args );
    while ( have_posts() ) : 
        the_post();

        the_title();

    endwhile;
    wp_reset_query();

    $latest_post_data_args = array(
        'cat'   => 4,
        'showposts' => 4,
        'offset'    => 1
    );
    query_posts( $latest_post_data_args );

    while ( have_posts() ) : 
        the_post();

        the_title();
        endwhile;
            dot1_get_nav(); 
    wp_reset_query(); 
?>
  • So where would the navigation go in relation to my code currently? – dkris Nov 8 '13 at 13:39
  • your code would repeat pagination for every post in the loop. – Milo Nov 8 '13 at 16:20
  • ^ And it does :-) It also doesn't change the posts retrieved :/ – dkris Nov 8 '13 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.