WordPress first post only on first page different then others

Got the next code to get the first WordPress post on only the first page to be different. But it doesn’t work. Looked at other questions and answers but there doesn’t seem to be a good answer for this.

This is what i’ve got but isn’t working for me:

Read More
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 5, 'paged' => $paged );
query_posts($args); ?>

<?php if (have_posts()) : ?>
<?php $postcount = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $postcount++; ?>

    <?php if ($postcount == 1 && $paged == 1) : // if this is the first post & first page ?>
    <div class="large-10">
    <?php the_post_thumbnail('large'); ?>
    </div>

        <?php else : //if this is NOT the first post ?>         
        <div class="large-6 columns">
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="portfolio">
            <a href="<?php the_permalink(); ?>">
            <?php the_post_thumbnail('large'); ?>
            <span><h6><?php the_title(); ?></h6></span>
            </a>
        </div>

        </article>
        </div>

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

I get this syntax error “unexpected T_ENDWHILE” but can’t figure out why.
Does anyone know how to properly get this done?

Thanks in advance!

Joeri

Related posts

Leave a Reply

1 comment

  1. It looks like you don’t have an endif for that inner if. Perhaps should be:

       <?php if ($postcount == 1 && $paged == 1) : // if this is the first post & first page ?>
        <div class="large-10">
        <?php the_post_thumbnail('large'); ?>
        </div>
    
        <?php else : //if this is NOT the first post ?>         
            <div class="large-6 columns">
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <div class="portfolio">
                <a href="<?php the_permalink(); ?>">
                <?php the_post_thumbnail('large'); ?>
                <span><h6><?php the_title(); ?></h6></span>
                </a>
            </div>
    
            </article>
            </div>
       <?php endif; ?>