Vinayak Vinayak - 20 days ago 5
HTML Question

Wordpress only first post different design

I have a blog(offline making) and I have Made a wordpress loop it checks if the First post it it uses different style and rest of other posts uses different.

Problem is: It works fine but when I go to next page(2) it shows again, I only want to apply for only First latest post. Not for First post on every page.

Code:

<?php
while ( have_posts() ) : the_post();?>
<?php $count++; ?>
<?php if ($count == 1 && is_home()) :

//First post different style goes here

<?php else : ?>

//Rest Other post different style goes here

<?php endif; ?>
<?php
endwhile;
?>

<?php else : ?>

<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->

<div class="page_content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->

<?php endif; ?>

Answer

You should use get_query_var('paged'). It will return the current page number, starting from 0.

So you should add

<?php if ($count == 1 && is_home() && get_query_var('paged') == 0 ) : ?>
    //First post different style goes here
<?php else : ?>
    //Rest Other post different style goes here 
<?php endif; ?>