Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
possible duplicate of How to fix pagination for custom loops? –  Chip Bennett Nov 8 '13 at 13:35
    
Problem is, I don't understand that post :/ –  dkris Nov 8 '13 at 14:06
    
Also a duplicate of this question: wordpress.stackexchange.com/questions/121486/… –  Chip Bennett Nov 8 '13 at 14:08
    
Again, that user's issue, although similar, hasn't been solved and doesn't work –  dkris Nov 8 '13 at 16:37
add comment

1 Answer

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(); 
?>
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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