Looping With Pagination Not Working

Hi!

This time i will share something great to you, it is about the WordPress Looping. Sometimes, you may want to have blog page layout with pagination on your site, it can be a normal page or a static page (WordPress dashboard > Settings > Reading).

The problem we usually got (all of ColorLabs theme have this problem) is when we set those blog page become static, the pagination is not working

At this post, i will share to you a WordPress looping that will work with a normal page and also static page. The structure is like this one:

<?php 
		if ( get_query_var('paged') ) {
            $paged = get_query_var('paged');
        } elseif ( get_query_var('page') ) {
            $paged = get_query_var('page');
        } else {
            $paged = 1;
        }
        query_posts( array( 'post_type' => 'post', 'paged' => $paged ) );
        if ( have_posts() ) : $count = 0; while ( have_posts() ) : the_post(); $count++;
    ?>

	<?php your_content_here(); ?>
    <?php endwhile;endif;?>  
	<?php your_pagination_functions_here();?>

You can also modify those looping if you want to displaying a custom post type.

Ok, that’s it what i want to share today. Have fun!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s