InfiniteScroll and WordPress Conditional
<p>I'm using 'Infinite scroll, but only want to call it if there are more than 8 posts. This doesn't seem to be working</p>

<pre><code>&lt;?php 
    $count_posts = wp_count_posts();
    $published_posts = $count_posts-&gt;publish;
    if ( is_home() || is_category() || is_archive() &amp;&amp; $published_posts &gt;= 8  ) { ?&gt;
    $container.infinitescroll({
        navSelector  : '#nav-below',
        nextSelector : '#nav-below .nav-previous a',
        itemSelector : '.entries',
        bufferPx: 10000,
        loading: {
            img: "&lt;?php echo get_template_directory_uri(); ?&gt;/library/images/ajax-loader.gif",
            msgText: "&lt;?php _e( 'Loading the next set of posts...', 'custom' ); ?&gt;",
            finishedMsg: "&lt;?php _e( 'All content loaded.', 'custom' ); ?&gt;"
        },
        debug: false,
        animate: false
    },
    function( newElements ) {
        var $newElems = $( newElements ).css({ opacity: 0 });
        $newElems.imagesLoaded(function(){
            $newElems.animate({ opacity: 1 });
            $container.masonry( 'appended', $newElems, true );
        });
    }
    );

    &lt;?php } ?&gt;
</code></pre>
