• Hi, I’m using The Unstandard theme. It displays posts with images using custom fields. On the main page it uses this to start querying for posts:
    <?php $top_query = new WP_Query('showposts=1'); ?>
    and then it uses this to show the rest (8 posts)
    <?php query_posts('showposts=9'); ?>

    The image for the first post (the last i’ve written, of course) is bigger than the 8 other posts that are displayed. All great, but since it doesn’t use the Loop for this, I can’t have “Next or Previous Entries” buttons. Well, I can have them but they don’t work.

    Soooooo…

    I want to be able to recognize my last post on the loop so I can put a bigger image for it, and smaller images for the rest.

    I wonder if I’m also able to get an impair number of posts only for the main page and any next or previous pages get pair numbers of posts. This, since only the main page has 1 post that has a double size image….

    Thanks! and hope it’s clear and simple!

Viewing 4 replies - 1 through 4 (of 4 total)
  • There is a plugin to customize how many post display on a page: Different Posts Per Page.

    I used the following snippet, on home.php template, to make the first post on the homepage larger. It adds an extra class to the first post which I use to stylize the post. You can certainly modify it for your use.

    <?php $post_i = 0 ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <li <?php
    	// if it is the first post, then mark it with a special class
    	++$post_i;
    	if($post_i == 1){
    		?>class="first-post"<?php
    	}
    ?>  id="post-<?php the_ID(); ?>">
    
    ...post template stuff here
    
    </li>
    <?php endwhile; ?>
    Thread Starter manuelxx

    (@manuelxx)

    Thanks!

    I’ve managed to get this done by getting another query that will always get me the last post i’ve written as No. 1. (this is from The Loop Codex page)

    <?php $my_query = new WP_Query('showposts=1');
        while ($my_query->have_posts()) : $my_query->the_post();
            $my_first = $post->ID;?>
            <!-- Do stuff... -->
        <?php endwhile; ?>

    Does that plugin allow me to set different number of posts for my first page and another number of posts for the rest of the pages? I’m talking about pagination and not Pages.

    Thanks again!!

    Sort of. The plugin allows you to set how many posts are displayed depending on the type of index. You could have the category indexes only display 5 posts where as the date indexes will show 8. This will let you set the number of posts for home; but this will also effect the number of posts on page two from home.

    If you want to have only 5 posts on page 1 of indexes and then 10 posts on all the other pages of an index, then this plugin will not do it.

    Thread Starter manuelxx

    (@manuelxx)

    yeah, i was afraid so…

    i’m trying to include one more post on the rest of the index pages than the number on the first index page. i even tried to get one less post, since that would also let me with an even number of posts…. no luck thou

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I recognize my last post on the Loop’ is closed to new replies.