max_num_pages;
if (!$pages) {
$pages = 1;
}
}
if (1 != $pages) {
echo "
";
echo "";
if ($paged > 2 && $paged > $range + 1 && $showitems < $pages){
echo "- «
";
}
if ($paged > 1 && $showitems < $pages){
echo " ";
}
for ($i = 1; $i <= $pages; $i++) {
if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems )) {
echo ($paged == $i) ? "- " . $i . "
" : "- " . $i . "
";
}
}
if ($paged < $pages && $showitems < $pages){
echo " ";
}
if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages){
echo "- »
";
}
echo "
\n";
}
}
/**
* Blog Page Pagination
* Ajax Pagination
* Load More & Infinite scrolling Paginetion
*
*/
add_action('wp_ajax_nopriv_more_post_ajax', 'more_post_ajax'); // load more
add_action('wp_ajax_more_post_ajax', 'more_post_ajax');
add_action('wp_ajax_infinite_scroll', 'infinite_post_ajax'); // scroll
add_action('wp_ajax_nopriv_infinite_scroll', 'infinite_post_ajax');
function more_post_ajax(){
scrollPostCalling($_POST,'load_more');
}
function infinite_post_ajax(){
scrollPostCalling($_POST,'infinite');
}
function scrollPostCalling($post,$scroll){
$paged = $_POST["paged"];
header("Content-Type: text/html");
$args = array(
'post_type' => 'post',
'paged' => $paged,
);
$loop = new WP_Query($args);
global $grid_layout;
if($grid_layout == 'standard-layout'):
// Start the post formate loop.
while ($loop->have_posts()) : $loop->the_post();
get_template_part( 'content', get_post_format() );
endwhile;
else :
// Start the post formate grid.
while ($loop->have_posts()) : $loop->the_post();
get_template_part( 'content', 'grid');
endwhile;
endif;
// If no content, include the "No posts found" template.
exit;
}
// load more ajax
function th_load_more_ajax(){
global $wp_query;
echo "";
?>