Skip to content

Instantly share code, notes, and snippets.

@raiden808
Created January 22, 2019 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raiden808/e9c82fec988e46f9539c4bf23723cff0 to your computer and use it in GitHub Desktop.
Save raiden808/e9c82fec988e46f9539c4bf23723cff0 to your computer and use it in GitHub Desktop.
function more_post_ajax(){
$offset = $_POST["offset"];
$ppp = $_POST["ppp"];
header("Content-Type: text/html");
$args = array(
'post_type' => 'post',
'posts_per_page' => $ppp,
'offset' => $offset,
);
$loop = new WP_Query($args);
while ($loop->have_posts()) { $loop->the_post();
echo '<li>' . get_the_title() . '</li>';
}
exit;
}
add_action('wp_ajax_nopriv_more_post_ajax', 'more_post_ajax');
add_action('wp_ajax_more_post_ajax', 'more_post_ajax');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment