while($q->have_posts()) {
$q->the_post();
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'thumbnail', true);
echo '<img src="'. $image_url.'" />';
}
function custom_pagination($numpages = '', $pagerange = '', $page='') {
if (empty($pagerange)) {
$pagerange = 2;
}
if ($numpages == '') {
global $wp_query;
$numpages = $wp_query->max_num_pages;
if(!$numpages) {
$numpages = 1;
}
}
$pagination_args = array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'total' => $numpages,
'current' => $page,
'show_all' => true,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => false,
'prev_text' => false,
'next_text' => false,
'type' => 'plain',
'add_args' => false,
'add_fragment' => ''
);
$paginate_links = paginate_links($pagination_args);
if ($paginate_links) {
echo "<div class='pagination'>";
echo $paginate_links;
echo "</div>";
}
}
if ( is_front_page() ) {
$paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
}
else {
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
}
$args = array(
// ...
'paged' => $paged,
'page' => $paged,
// ...
);