<?php
include $_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-blog-header.php';
$num = $_GET['num'];
$offset = $num * 2 + 1;
query_posts('cat=2&posts_per_page=3&offset=' . $offset);
$answer = '';
while (have_posts()) : the_post();
$answer += '<div class="smallpost"><a href="' . the_permalink() . '" class="header_smallpost">' . the_title() . '</a>
<span class="date">' . the_time(__('j F H:i')) . '</span></div>';
endwhile;
echo $answer;
?>
num = 1;
function loadMore() {
num += 1;
if (window.XMLHttpRequest) {
var xmlhttp = new XMLHttpRequest();
} else {
var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
document.getElementById('smallposts').innerHTML += xmlhttp.responseText;
}
xmlhttp.open('GET', '<?php echo get_template_directory_uri(); ?>/loadmore.php?num=' + num, true);
xmlhttp.send();
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
document.getElementById('smallposts').innerHTML += xmlhttp.responseText;
}
}
$answer .= '<div class="smallpost"><a href="' . get_the_permalink() . '" class="header_smallpost">' . get_the_title() . '</a>
<span class="date">' . get_the_time(__('j F H:i')) . '</span></div>';
get_the_permalink()
xhr.onreadystatechange = function () {
var html, status;
if (xhr.readyState == 4) {
if ((status = xhr.status) >= 200 && status < 400) {
html=xhr.responseText;
//code
}else{
//error status
}
}
}