I am trying to make a pagination from meta_post (meta_key
,meta
_value) ==> (name_student,array(john,mike,natasha,joan,buck)
) but i dont know how to make it, from codex just make pagination post , not a meta_post , and my meta_post in 1 array
, i was find a similar question 1 , 2 , but I still haven't found the answer for my problem , if anyone can help me to find sollution for my problem I will be greatly helped , thankyou for read my problem , hopefully can help me
this my code :
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$ids = get_the_ID();
$args = array('paged' => $paged , 'post__in' => array($ids));
$the_query = new WP_Query($args);
if (have_posts()) :
while (have_posts()) : the_post();
$metas = get_post_meta(get_the_ID(),'name_student',false);
foreach ($metas as $meta) {
$key_val = explode(",", $meta);
$image_chunk = array_chunk($key_val, 3);
$page = get_query_var('page');
$page = $page > 1 ? $page - 1 : 0 ;
if (isset($key_val[$page])) {
foreach ($image_chunk[$page] as $image) {
echo "<div class='col-lg-4'>".
wp_get_attachment_image($image,"thumbnail") ."</div>";
}
}
}
endwhile;
$big = 9999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
wp_reset_postdata();
endif;