• My index and archives (both use index.php) display a html block after the sticky posts and before the normal posts. But the number of stickies displayed changes on a daily basis. And I’m currently manually adjusting some “insert after x number of posts” code accordingly. But that obviously sucks.

    A sticky post will nearly always exist for the homepage, but the archives not so much. So I really need a “if no sticky exist, insert before normal posts”.

    I’m currently using this code, but hoping there exists a better (non-manual-adjusting) solution.

    <?php $count = 1; ?>
       	        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<?php if ($count == 6) : ?>
                 <!-- In-Page Ad -->
    		<div class="box">This block is after stickies, and before normal posts. If no stickies exist, must be before normal posts.</div>
    			<?php endif; $count++; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘If Stickies, insert AFTER Stickies. else insert before normal posts?’ is closed to new replies.