Custom Post Type Pagination
-
I’m trying to get pagination to work correctly with a video thumbnail gallery based on a custom post type called “videos.”
I am using a custom loop to pull in the videos and thumbnails and wp pagenavi plugin.
I can get the videos to display correctly OR the pagenavi to display correctly, but not both at the same time.Any help would really be appreciated.
Here’s the code I’m using with thesis theme:
function thesis_video_gallery() { $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => 'videos', 'posts_per_page' => 12, 'caller_get_posts' => 1, 'paged' => $paged ) ); if ( is_page('scleroderma-video-gallery') && !is_single() ){ global $post; $args = (array( 'post_type' => 'videos')); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $post_image = thesis_post_image_info('thumb'); ?> <div id="vid-gallery"> <div class="vid-thumb"> <a>ID, $key, true); ?>" rel="shadowbox" title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, 'youtube_thumb', true) ?>" alt="<?php the_title(); ?>"></a></div> <div class="vid-title"> <h2><a>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </div> </div> <?php endwhile; if(function_exists('wp_pagenavi')) wp_pagenavi(); wp_reset_query(); } } add_action('thesis_hook_after_content', 'thesis_video_gallery');
Viewing 1 replies (of 1 total)
-
Ok,
I moved the query under my if statement and got it to work:
here’s the final code I used:function thesis_video_gallery() { if ( is_page('scleroderma-video-gallery') && !is_single() ){ global $post; $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = (array( 'post_type' => 'videos', 'posts_per_page' => 12, 'caller_get_posts' => 1, 'paged' => $paged )); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $post_image = thesis_post_image_info('thumb'); query_posts( array( 'post_type' => 'videos', 'posts_per_page' => 12, 'caller_get_posts' => 1, 'paged' => $paged ) ); ?> <div id="vid-gallery"> <div class="vid-thumb"> <a href="<?php $key="lightbox_url"; echo get_post_meta($post->ID, $key, true); ?>" rel="shadowbox" title="<?php the_title(); ?>"><img src="<?php echo get_post_meta($post->ID, 'youtube_thumb', true) ?>" alt="<?php the_title(); ?>"></a></div> <div class="vid-title"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </div> </div> <?php endwhile; if(function_exists('wp_pagenavi')) wp_pagenavi(); wp_reset_query(); } } add_action('thesis_hook_after_content', 'thesis_video_gallery');
Viewing 1 replies (of 1 total)
The topic ‘Custom Post Type Pagination’ is closed to new replies.