Function which may be called in Ajax to Load News
function load_more_news()
{
$offset = $_POST["offset"];
$wpb_all_query = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => 'news',
'posts_per_page' => 3,
'offset' => $offset
)
);
$posts = array();
foreach ($wpb_all_query->get_posts() as $post) {
if (has_post_thumbnail($post->ID)) {
$attachment_ids[0] = get_post_thumbnail_id($post->ID);
$attachment = wp_get_attachment_image_src($attachment_ids[0], 'full');
$post->thumbnail = $attachment[0];
}
array_push($posts, $post);
}
echo json_encode($posts);
die();
}