Advertisement
ndrwld

Pagination problem in selected custom taxonomy term (WP)

Jun 7th, 2011
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1.         /* Some info:
  2.          * http://wordpress.stackexchange.com/questions/13888/retrieve-single-term-slug
  3.          * http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters
  4.          */
  5.         $term_slug = get_queried_object()->slug;
  6.         if ( !$term_slug )
  7.             return;
  8.             else
  9.         $args = array(
  10.             'tax_query' => array(
  11.                 array(
  12.                     'post_type' => 'gallery',
  13.                     'taxonomy' => 'gallery_category',
  14.                     'field' => 'slug',
  15.                     'terms' => $term_slug
  16.                 )
  17.             ),
  18.             'posts_per_page' => 3,
  19.             'paged' => get_query_var( 'paged' )
  20.         );
  21.         $loop = new WP_Query( $args );
  22.             while ( $loop->have_posts() ) : $loop->the_post(); ?>
  23.  
  24.             <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  25.                 <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'poznaj-wilno' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  26.                 <div class="entry-thumbnail">
  27.                     <?php if ( has_post_thumbnail() ) : ?>
  28.                         <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'poznaj-wilno' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( 'gallery-thumbnail' ); ?></a>
  29.                     <?php endif; ?>
  30.                 </div><!-- .entry-thumbnail -->        
  31.             </div><!-- #post-## -->            
  32.             <?php endwhile; // End the loop. Whew.
  33. /*Using WP-PageNavi plugin.
  34. * Call based on - http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html
  35. */ ?>
  36. <div class="pagination">
  37. <?php
  38.     if ( function_exists('wp_pagenavi') )
  39.  wp_pagenavi( array( 'query' => $loop ) );
  40. ?>
  41. </div><!-- .pagination -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement