Set up a simple counter variable that increments during each pass of the Loop. Then test the variable to determine which post is currently being process. Once you have the right post, you can output it using different markup, template tags etc.
<?php $c =0;
if (have_posts()) : while (have_posts()) : the_post();
$c++;?>
<?php if($c == 1) :?>
[ markup for first post ]
<?php else:?>
[ standard markup for the rest of the posts ]
<?php endif;?>
<?php endwhile; ?>
[...]
<?php endif; ?>
Thank you that worked PERFECTLY!!!
that worked perfectly, but now I am trying to just have that on the home page I’ve tried the “php if (is_home)” but I think I’m doing it wrong because I keep getting an error.
I kind of want it to work like this
Home Page: http://www.elucidation-art.com/webdev/blog.php
page two: http://www.elucidation-art.com/webdev/archive.php
and when you get go to page two off the home page to look like the above (except without the “Archive Title Or Category Title” and paragraph at the top of the page.
thank you, using the !is_page() tag I’ve managed to get ride of the featured post on the pages after the home page, still having a slight problem getting the second style to change.
<?php $c =0;
if (have_posts()) : while (have_posts()) : the_post();
$c++;?>
<?php if( ($c == 1) && !is_paged(page) ) :?>
//FEATURE POST MARKUP
<?php elseif (!is_page(page)) :?>
//HOME PAGE POST MARK UP
<?php else :?>
//ALL OTHER PAGES STYLES
<?php endif;?>
<?php endwhile; ?>
this ignores the last else and just replicates the //home page post mark up on the second page.
the general usage is is_paged() with empty brackets; i don’t know if having something in the bracket will interfere with the result.
also, instead of:
<?php else :?>
//ALL OTHER PAGES STYLES
you could try explicitely:
<?php elseif (is_paged()) :?>
//ALL OTHER PAGES STYLES
no it doesn’t seem to affect anything its still showing home page post style on the second page.
EDIT:
I’ve done it…. although its not perfect it does work, so if anyone else had any ideas to do it better without the n00b php here is what I’ve done.
<?php $c =0;
if (have_posts()) : while (have_posts()) : the_post();
$c++;?>
<?php if( ($c == 1) && !is_paged(page) ) :?>
//FEATURED POST MARKUP
<?php elseif (($c = 7) && !is_paged(page)) :?>
//HOME PAGE POST DISPLAY MARK UP, UP TO 7 POSTS ($c = 7) IS WHERE I PUT THE AMOUNT OF POSTS I WANTED TO DISPLAY ON THE HOME PAGE.
<?php else :?>
// MARK UP FOR ALL OTHER PAGES
<?php endif;?>
<?php endwhile; ?>
hello, you found a solution to your needs?
I would have the same need but do not know how.
Thank you.