WordPress posts repeating

Mar 13, 2012   //   by phpfreelancer.biz   //   Blog, Wordpress Theme Tutorial  //  No Comments

I am using the Imbalance two theme for WordPress and I have created a new loop to deal with a different page as I have got one category directing to a page, however the posts that are on the page when first loaded are just repeating as I scroll down the page.

It is using an ajax thing to load on scroll. Below is my code for the new loop:

<!--?php if ( ! have_posts() ) : ?--></pre>
<div id="post-0" class="post error404 not-found">
<h1 class="entry-title"></h1>
<div class="entry-content">
<!--?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'imbalance2' ); ?-->

 <!--?php get_search_form(); ?--></div>
<!-- .entry-content --></div>
<pre>
<!-- #post-0 -->
<!--?php endif; ?-->

<!--?php $imbalance2_theme_options = get_option('imbalance2_theme_options') ?--></pre>
<div id="boxes"><!--?php while ( have_posts() ) : the_post(); ?-->
<div class="box">
<div class="rel">
 <!--?php if ($imbalance2_theme_options['images_only'] == 0): ?-->
<h1 style="padding-top: 8px; padding-bottom: 2px;"></h1>
 <!--?php the_excerpt() ?-->
<div class="categories" style="padding-top: 5px;"><!--?php                     $key = 'title';                     $themeta = get_post_meta($post--->ID, $key, TRUE);
 if($themeta != '') {
 echo "<strong>Job Title: </strong>";
 echo $themeta;
 }
 ?>

 <!--?php                     $key = 'location';                     $themeta = get_post_meta($post--->ID, $key, TRUE);
 if($themeta != '') {
 echo "<strong>Location: </strong>";
 echo $themeta;
 }
 ?></div>
<div class="posted"><!--?php imbalance2_posted_on() ?--> <span class="main_separator">/</span>
 <!--?php echo comments_popup_link( __( 'No comments', 'imbalance2' ), __( 'One Comment', 'imbalance2' ), __( '% Comments', 'imbalance2' ) ); ?--></div>
 <!--?php endif ?-->
<div class="texts"><!--?php if ($imbalance2_theme_options['images_only'] == 1): ?-->

 <!--?php endif ?-->
<div class="abs"><!--?php if ($imbalance2_theme_options['images_only'] == 0): ?-->

 <!--?php endif ?-->
<h1 style="padding-top: 8px; padding-bottom: 2px;"></h1>
 <!--?php the_excerpt() ?-->
<div class="categories" style="padding-top: 5px;"><!--?php                     $key = 'title';                     $themeta = get_post_meta($post--->ID, $key, TRUE);
 if($themeta != '') {
 echo "<strong>Job Title: </strong>";
 echo $themeta;
 }
 ?>

 <!--?php                     $key = 'location';                     $themeta = get_post_meta($post--->ID, $key, TRUE);
 if($themeta != '') {
 echo "<strong>Location: </strong>";
 echo $themeta;
 }
 ?></div>
 <!--?php the_excerpt() ?-->
<div class="posted"><!--?php imbalance2_posted_on() ?--> <span class="main_separator">/</span>
 <!--?php echo comments_popup_link( __( 'No comments', 'imbalance2' ), __( 'One Comment', 'imbalance2' ), __( '% Comments', 'imbalance2' ) ); ?--></div>
</div>
</div>
</div>
</div>
<!--?php endwhile; ?--></div>
<pre>
<!--?php if ( $wp_query--->max_num_pages > 1 ) :
    if ( $imbalance2_theme_options['navigation'] == 0 ) : // Default ?></pre>
<div class="fetch"></div>
<pre>
<script type="text/javascript">// <![CDATA[
// Ajax-fetching "Load more posts"
$('.fetch a').live('click', function(e) {
    e.preventDefault();
    $(this).addClass('loading').text('Loading...');
    $.ajax({
        type: "GET",
        url: $(this).attr('href') + '#boxes',
        dataType: "html",
        success: function(out) {
            result = $(out).find('#boxes .box');
            nextlink = $(out).find('.fetch a').attr('href');
            $('#boxes').append(result).masonry('appended', result);
            $('.fetch a').removeClass('loading').text('Load more posts');
            if (nextlink != undefined) {
                $('.fetch a').attr('href', nextlink);
            } else {
                $('.fetch').remove();
            }
        }
    });
});
// ]]></script>

    <!--?php elseif ( $imbalance2_theme_options['navigation'] == 1 ) : // Infinite scroll ?--></pre>
<div class="infinitescroll"></div>
<pre>
<script type="text/javascript">// <![CDATA[
// Infinite Scroll
var href = 'first';
$(document).ready(function() {
    $('#boxes').infinitescroll({
        navSelector : '.infinitescroll',
        nextSelector : '.infinitescroll a',
        itemSelector : '#boxes .box',
        loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
        loadingText : 'Loading...',
        donetext : 'No more pages to load.',
        debug : false
    }, function(arrayOfNewElems) {
        $('#boxes').masonry('appended', $(arrayOfNewElems));
        if (href != $('.infinitescroll a').attr('href'))
        {
            href = $('.infinitescroll a').attr('href');
        }
    });
});
// ]]></script>

    <!--?php endif; ?-->

<!--?php endif; ?-->

Because you have two the_excerpt() inside one loop, on line 54 and 73.

Leave a comment

Share This Post

RSS Wordpress News