• I’m trying to develop my own WordPress theme, but I’m stuck on the index.php page. I don’t have much experience with php code, so not understanding correctly where things should be placed to work correctly.

    What I’m attempting to do is have the first (latest) post show the full content, then remaining posts styled differently. I have the styling already set – it’s the php code I’m struggling with.

    Here’s what I have so far:

    <?php if (have_posts()) : ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<?php if( $wp_query->current_post == 0 && !is_paged() ) { /*first post*/ } ?>
    
    	<!-- first post divs and styling here -->
    <?php the_content();?>
    
    <!-- if I put a php else here, it breaks the theme -->
    
            <!-- remaining post info and styling here -->
    <?php the_excerpt(); ?>
    
    <?php endwhile; ?>
    
    <?php endif; ?>

    I’ve googled this and found various different codes which people say work, but I have no idea where I should place them, or whether the other loop needs to be moved or removed.

    Any help at all would be fantastic as I’ve been stuck on this for over 3 weeks now.

    Thanks in advance.

The topic ‘First Post in Loop different to remaining posts (index.php help)’ is closed to new replies.