• When I select Load More Posts, it now shows posts n-1, n-2, n-3, n-4, n-5 as duplicates before showing n-6… and so on. This appears to have started at some point after adding sufficient number of posts to the blog. Can anyone point me in the right direction? The button to load more appears to call a getNews method which I cannot seem to find via the admin console – though admittedly I am a WordPress novice. Any help is appreciated!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • That looks like something that your theme has done, or it’s from a plugin that’s been added. WordPress doesn’t have that “read more” AJAX functionality out-of-the-box.

    The first thing that I’d do is go back to the company that developed your theme and ask them. As your theme looks like it’s all been custom-developed, we can’t see any part of how it works from here.

    Thread Starter jennyaves

    (@jennyaves)

    Could this be the offending code:

    function getNewsAJAX()
    {
    global $wpdb, $post;
    $offset = (int)$_POST[‘offset’]; //yyyymmdd

    $args = array(
    ‘post_type’ => ‘post’,
    ‘order’=> ‘DESC’,
    ‘orderby’ => ‘date’,
    ‘offset’ => $offset,
    ‘posts_per_page’ => 6
    );
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) :
    while ($the_query->have_posts()) : $the_query->the_post();

    $callback[‘news’][] = array(
    ‘date’ => get_the_date(‘d.m.y’),
    ‘title’ => get_the_title(),
    ‘link’ => get_the_permalink(),
    ‘post_thumbnail’ => get_the_post_thumbnail_url(get_the_ID(),’large’)
    );

    endwhile; endif;

    $counter = 0;
    $callback[‘morePosts’] = 0;

    $args = array(
    ‘post_type’ => ‘post’,
    ‘orderby’ => ‘date’,
    ‘order’ => ‘DESC’,
    ‘offset’ => $offset+6
    );
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) :
    while ($the_query->have_posts()) : $the_query->the_post();
    $counter++;
    endwhile; endif;

    if($counter > 0 ) $callback[‘morePosts’] = 1;

    echo json_encode($callback);

    wp_die();
    }`

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load More Posts showing duplicate entries’ is closed to new replies.