Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Custom post type with pagination
- // Reference link for first one https://stackoverflow.com/questions/15524195/wordpress-custom-post-page-with-pagination
- <?php
- $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
- $ic_gallery= new WP_Query(array(
- 'post_type'=>'gallery',
- 'posts_per_page' => 12,
- 'paged' => $paged,
- ));
- if($ic_gallery->have_posts()) : while($ic_gallery->have_posts()) : $ic_gallery->the_post();
- ?>
- <div class="ic-single-g-item">
- <?php the_post_thumbnail('gallery'); ?>
- <div class="ic-title-n-cat">
- <h3><?php the_title(); ?></h3>
- <span><?php the_content(); ?></span>
- </div>
- </div>
- <?php endwhile; ?>
- <div class="ic-gallery-navigation">
- <?php
- $total_pages = $ic_gallery->max_num_pages;
- if ($total_pages > 1){
- $current_page = max(1, get_query_var('paged'));
- echo paginate_links(array(
- 'base' => get_pagenum_link(1) . '%_%',
- 'format' => '/page/%#%',
- 'current' => $current_page,
- 'total' => $total_pages,
- 'prev_text' => __('Previous'),
- 'next_text' => __('Next'),
- ));
- }
- ?>
- </div>
- <?php else :?>
- <h1 style="color: red; padding: 30px; text-align: center;"><?php _e("Sorry no posts found, please go to dashboard and post from 'Team Member' menu"); ?></h1>
- <?php endif; wp_reset_query(); ?>
Add Comment
Please, Sign In to add comment