Skip to content

Instantly share code, notes, and snippets.

@ajaydsouza
Last active April 27, 2019 16:18
Show Gist options
  • Save ajaydsouza/690784c903242397a351 to your computer and use it in GitHub Desktop.
Save ajaydsouza/690784c903242397a351 to your computer and use it in GitHub Desktop.
Ajax Load More implementations
<?php
/*
* This example fetches the related posts and uses Ajax Load More to dynamically pull additional posts
*
*/
global $post;
$features = get_crp_posts_id( array(
'postid' => $post->ID,
'limit' => 7
) );
$features = wp_list_pluck( (array) $features, 'postnumber' );
if ( $features ) {
//Implode the posts and set a varible to pass to our exclude param.
$posts_in = implode( ",", $features );
}
echo do_shortcode( '[ajax_load_more post__in="' . $posts_in . '" orderby="post__in"]' );
<?php
/*
* This example fetches the popular posts and uses Ajax Load More to dynamically pull additional posts
*
*/
$features = get_tptn_pop_posts(); // Array of posts
$features = wp_list_pluck( (array) $features, 'postnumber' );
if ( $features ) {
//Implode the posts and set a varible to pass to our exclude param.
$posts_in = implode( ",", $features );
}
echo do_shortcode( '[ajax_load_more post__in="' . $posts_in . '" orderby="post__in"]' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment