Photogram Gallery Pagination Error

Today, i’m trying to discover Photogram deeper and suddenly i found a bug on this theme. Maybe, you already found this bug.

The bug is happened when you create a gallery that displaying a post or photographs. If you take a look into the code (template-gallery.php) you will found a pagination code after the post and photographs looping.

The problem now is: where is the pagination when you create a gallery template?

Because of JavaScript code make my eye tired 🙂 i will not take a look into the scroll pagination. This time i more prefer to displaying a default pagination from ColorLabs. To do it, you have to modify 2 files: template-gallery.php and style.css.

Step#1

Open template-gallery.php file and find out this code:

<?php
		if(get_post_meta($post->ID,'meta_style_gallery',true)=='photograph'){
		$photograph = new WP_Query(array('post_type' => 'photograph', 'paged' => $paged ));
			while ($photograph->have_posts()) : $photograph->the_post();
				get_template_part('content','photograph');
			endwhile;
			if (  $photograph->max_num_pages > 1 ) : ?>
					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'colabsthemes' ) ); ?></div>
			<?php endif;

Edit that code become:

<?php
		if(get_post_meta($post->ID,'meta_style_gallery',true)=='photograph'){
		$photograph = new WP_Query(array('post_type' => 'photograph', 'paged' => $paged ));
			while ($photograph->have_posts()) : $photograph->the_post();
				get_template_part('content','photograph');
			endwhile;
			echo '<div class="pagcover">';
				colabs_pagination('',$latest);
			echo '</div>';
			 ?>

			<?php

Then find out this code:

$cat_id = get_post_meta($post->ID, "cat",true);
			if($cat_id > 0):
				$args = array('post_type' => 'post', 'post__not_in' =>get_option('sticky_posts'), 'paged' => $paged, 'cat' => $cat_id);
			else:
				$args =array('post_type' => 'post', 'post__not_in' =>get_option('sticky_posts'), 'paged' => $paged );
			endif;
			$latest = new WP_Query( $args );
			if($latest->have_posts()): while($latest->have_posts()): $latest->the_post();
				get_template_part('content','photograph');
			endwhile; endif;
			if (  $wp_query->max_num_pages > 1 ) : ?>
					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'colabsthemes' ) ); ?></div>
			<?php endif;
		}

Modify that code become:

$cat_id = get_post_meta($post->ID, "cat",true);
			if($cat_id > 0):
				$args = array('post_type' => 'post', 'post__not_in' =>get_option('sticky_posts'), 'paged' => $paged, 'cat' => $cat_id);
			else:
				$args =array('post_type' => 'post', 'post__not_in' =>get_option('sticky_posts'), 'paged' => $paged );
			endif;
			$latest = new WP_Query( $args );
			if($latest->have_posts()): while($latest->have_posts()): $latest->the_post();
				get_template_part('content','photograph');
			endwhile;

			echo '<div class="pagcover">';
				colabs_pagination('',$latest);
			echo '</div>';

			endif;
			 ?>

			<?php
		}

Step#2

At this step you have to modify a file named style.css. Put this code at the very end of the file:

.pagcover {
position: absolute;
bottom: -50px;
width: 100%;
}

And done! Your pagination already displayed on your gallery template.

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