chavewain
10/17/2015 - 7:48 AM

Wordpress - numeric pagination

Wordpress - numeric pagination

<?php

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts(array(
	'post_type'      => 'post', // You can add a custom post type if you like
	'paged'          => $paged,
	'posts_per_page' => 3
));

if ( have_posts() ) : ?>

<?php while ( have_posts() ) : the_post(); ?>

	<?php the_title(); ?><br>

<?php endwhile; ?>

	<?php my_pagination(); ?>

<?php else : ?>

        <?php // no posts found message goes here ?>
	
<?php endif; ?>
if ( ! function_exists( 'my_pagination' ) ) :
	function my_pagination() {
		global $wp_query;

		$big = 999999999; // need an unlikely integer
		
		echo paginate_links( array(
			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
			'format' => '?paged=%#%',
			'current' => max( 1, get_query_var('paged') ),
			'total' => $wp_query->max_num_pages
		) );
	}
endif;
function custom_thumbs()
{
    add_image_size( 'thumb-small', 200, 200, true ); // Hard crop to exact dimensions (crops sides or top and bottom)
    add_image_size( 'thumb-medium', 520, 9999 ); // Crop to 520px width, unlimited height
    add_image_size( 'thumb-large', 720, 340 ); // Soft proprtional crop to max 720px width, max 340px height
}
add_action( 'after_setup_theme', 'custom_thumbs' );