Pagination with custom post type question
-
Hi,
I’m trying to get a custom post to load on a page but for some reason it seems shows up every other kind of category post apart from the ones I actually want to load.
in functions file the code looks like:
add_action('init', 'gallery_register'); function gallery_register() { $labels = array( 'name' => _x('Photo Gallery', 'post type general name'), 'singular_name' => _x('Gallery Item', 'post type singular name'), 'add_new' => _x('Add New', 'gallery item'), 'add_new_item' => __('Add New Gallery Item'), 'edit_item' => __('Edit Gallery Item'), 'new_item' => __('New Gallery Item'), 'view_item' => __('View Gallery Item'), 'search_items' => __('Search Gallery'), 'not_found' => __('Nothing found'), 'not_found_in_trash' => __('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_icon' => get_stylesheet_directory_uri() . '/article16.png', 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','thumbnail') ); register_post_type( 'gallery' , $args ); } register_taxonomy("photo_categories", array("gallery"), array("hierarchical" => true, "label" => "Photos Categories", "singular_label" => "Photo", "rewrite" => true));
And on the page I’m trying:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array ( 'category_name' => $gallery, 'orderby' => 'date', 'posts_per_page' => '5' ); query_posts($args . '&paged=' . $paged); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail(); } ?> <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <p>by <?php the_author(); ?> on <?php the_time('F j, Y') ?></p> <p><?php echo get_the_excerpt(); ?></p> <?php endwhile; endif; ?> <?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); endif; wp_reset_query();?>
The Pagination side of things works it’s showing up the wrong categories?
Anyone have an ides?
Thanks!
- The topic ‘Pagination with custom post type question’ is closed to new replies.