Counter is skipping post when I still want it visible [closed]

Your logic in your code is wrong. Read your code in plain English.

If the current post is number 3, show my custom content, else, show the posts as normal.

What you want is the following

If the current post is number 3, show my custom content.

Show all my posts as normal

To achieve this, you need only wrap your custom content in your statement. So you need to rewrite your code as follow

<?php if ($count == 3) : ?>
    <div id="latest-news" class="col-lg-4" style="height:480px;">
        <h2>Latest News</h2>
    </div>
<?php endif ?>

FEW NOTES ON YOUR CODE

  • showposts is depreciated in favor of posts_per_page

  • Do not use :, endif and endwhile. Although it is totally valid php, it is hard to debug as most code editors don’t support this syntax. Use the old style curlies ({}). they are supported by all code editors and easy to debug

  • wp_reset_postdata() should go after your endwile and before endif. The reason for this is, you don’t need reset anything if you don’t have posts

ANOTHER APPROACH

Just as another idea, you can use the the_post action to add your custom content before post 3. You can try something like this as well

add_action( 'the_post', function ( $post ) 
{
    global $wp_query;

    if ( $wp_query->post != $post )
        return;

    if ( 2 != $wp_query->current_post )
        return;

    echo '<div id="latest-news" class="col-lg-4" style="height:480px;">
        <h2>Latest News</h2>
    </div>';    
});