• boon_

    (@boon_)


    Hey

    I’ve got something in the loop to change the class of post 3 – there are 3 posts per page, so the last one on the page.

    Which is fine but…If there are less than 3 posts then it doesn’t change the last post (to remove horizontal a line), which there will be on some archives for some categories / tags pages.

    Any idea so I can target exclusively the LAST post on the page..not post #3?

    I’ve tried a few code bits from other forum posts but can’t work it out ?? Here’s the loop..

    <?php if (have_posts()) : ?>
    <?php } ?>
    <ul class="blog">
    	<?php $postnum = 1; ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<?php if ($postnum ==3) { ?>
    		<li class="post_last">
    			Last Post
    		</li>
    	<?php } else { ?>
    		<li class="post">
    			Post
    		</li>
    	<?php $postnum++; ?>
    <?php } ?>
    <?php endwhile; ?>
    </ul><!-- end blog -->

    Also, I’ve got next and previous links set up in the archives for pagination..

    <ul class="next_prev">
        <li class="prev">
            <?php previous_posts_link('&laquo; Newer Posts') ?>
        </li>
        <li class="next">
            <?php next_posts_link('Older Posts &raquo;') ?>
        </li>
    </ul>

    Again, if there are less than 3 posts then it still obviously outputs the following code..

    <ul class="next_prev">
       <li class="prev"> </li>
       <li class="next"> </li>
    </ul>

    Is there any way I can write something to exclude the list altogether if there’s only 1 page of archives / no need for the links?

    Help much appreciated

    Thanks in advance
    Boon.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘The Loop – Last Post / Next & Prev’ is closed to new replies.