Forum Replies Created

Viewing 1 replies (of 1 total)
  • 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 1 replies (of 1 total)