Instantly share code, notes, and snippets.

@raiden808 raiden808/blog_3 Secret
Last active Jan 22, 2019

Embed
What would you like to do?
// ajax load more shortcode
function rda_blog_display_callback(){
$postsPerPage = 3;
$args = array(
'post_type' => 'post',
'posts_per_page' => $postsPerPage
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
echo "<div class='blog_wrapper'>";
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
echo "</div>";
} else {
// no posts found
}
echo '<a id="more_posts" href="#">Load More</a>';
}
add_shortcode( 'rda_blog_display', 'rda_blog_display_callback' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment