Advertisement
Guest User

taxonomy.php

a guest
Jan 6th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. <?php
  2. /**
  3. * The template for displaying Taxonomy pages.
  4.  
  5. *
  6. * Learn more: http://codex.wordpress.org/Template_Hierarchy
  7. *
  8. * @package WordPress
  9. * @subpackage Twenty_Twelve
  10. * @since Twenty Twelve 1.0
  11. */
  12.  
  13. get_header(); ?>
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. <section id="primary" class="site-content">
  21. <div id="content" role="main">
  22.  
  23. <header class="tag-header">
  24. <h1 class="tag-title">
  25.  
  26. <?php
  27.  
  28. $tax_name = get_query_var( 'taxonomy' );
  29.  
  30. $the_tax = get_taxonomy( get_query_var( 'taxonomy' ) );
  31. echo $the_tax->labels->name; ?>: <?php $args = array( 'taxonomy' => $tax_name );
  32.  
  33. $terms = get_terms($tax_name, $args);
  34.  
  35. $count = count($terms); $i=0;
  36. if ($count > 0) {
  37. $cape_list = '<p class="my_term-archive">';
  38. foreach ($terms as $term) {
  39. $i++;
  40. $term_list .= '<a href="#' . $term->slug . '" title="' . sprintf(__('Jump to %s posts', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a>';
  41. if ($count != $i) $term_list .= ' &middot; '; else $term_list .= '</p>';
  42. }
  43. echo $term_list;
  44. }; ?>
  45. </h1>
  46.  
  47.  
  48.  
  49. </header>
  50.  
  51.  
  52.  
  53. <?php
  54.  
  55. // List posts by the terms for a custom taxonomy of any post type
  56. $post_type = 'post';
  57. $tax = get_query_var( 'taxonomy' );
  58. $tax_terms = get_terms( $tax );
  59. if ($tax_terms) {
  60. foreach ($tax_terms as $tax_term) {
  61. $args = array(
  62. 'post_type' => $post_type,
  63. "$tax" => $tax_term->slug,
  64. 'post_status' => 'publish',
  65. 'posts_per_page' => -1,
  66. 'caller_get_posts'=> 1
  67. );
  68.  
  69. $my_query = null;
  70. $my_query = new WP_Query($args);
  71.  
  72. if( $my_query->have_posts() ) : ?>
  73.  
  74.  
  75. <h1 class="tag-subheader" id="<?php echo $tax_term->slug; ?>"><?php echo $tax_term->name; ?> <a class="alignrighthover" href="#top" title=""><img src="http://www.alittlebiteofeverything.com/wp-content/themes/alittlebite/images/arrow.png" border="0" height="20" width="16"></a></h1>
  76.  
  77. <div id="gridcontainer">
  78. <?php
  79. $counter = 1; //start counter
  80.  
  81. $grids = 4; //Grids per row
  82.  
  83. global $query_string; //Need this to make pagination work
  84.  
  85.  
  86. /*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
  87. query_posts($query_string . '&caller_get_posts=1&posts_per_page=64');
  88.  
  89.  
  90. if(have_posts()) : while( $my_query->have_posts() ) : $my_query->the_post();
  91. ?>
  92. <?php
  93. //Show the left hand side column
  94. if($counter == 1) :
  95. ?>
  96. <div class="griditemleft">
  97. <div class="postimage">
  98. <a class="hovereffect" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
  99. </div>
  100. <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  101.  
  102. <?php if( $recipetitle = get_post_meta($post->ID, 'recipetitle', true) ): ?> <?php echo apply_filters('the_content', $recipetitle); ?>
  103. <?php else: $recipetitle = the_title(); ?>
  104. <?php endif; ?>
  105. </a></h2>
  106. </div>
  107. <?php
  108. //Show the second column
  109. elseif($counter == 2) :
  110. ?>
  111. <div class="griditemsecond">
  112. <div class="postimage">
  113. <a class="hovereffect" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
  114. </div>
  115. <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  116. <?php if( $recipetitle = get_post_meta($post->ID, 'recipetitle', true) ): ?> <?php echo apply_filters('the_content', $recipetitle); ?>
  117. <?php else: $recipetitle = the_title(); ?>
  118. <?php endif; ?>
  119. </a></h2>
  120. </div>
  121. <?php
  122. //Show the third column
  123. elseif($counter == 3) :
  124. ?>
  125. <div class="griditemthird">
  126. <div class="postimage">
  127. <a class="hovereffect" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
  128. </div>
  129. <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  130. <?php if( $recipetitle = get_post_meta($post->ID, 'recipetitle', true) ): ?> <?php echo apply_filters('the_content', $recipetitle); ?>
  131. <?php else: $recipetitle = the_title(); ?>
  132. <?php endif; ?>
  133. </a></h2>
  134. </div>
  135.  
  136. <?php
  137. //Show the right hand side column
  138. elseif($counter == $grids) :
  139. ?>
  140. <div class="griditemright">
  141. <div class="postimage">
  142. <a class="hovereffect" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
  143. </div>
  144. <h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
  145. <?php if( $recipetitle = get_post_meta($post->ID, 'recipetitle', true) ): ?> <?php echo apply_filters('the_content', $recipetitle); ?>
  146. <?php else: $recipetitle = the_title(); ?>
  147. <?php endif; ?>
  148. </a></h2>
  149. </div>
  150. <div class="clear"></div>
  151. <?php
  152. $counter = 0;
  153. endif;
  154. ?>
  155. <?php
  156. $counter++;
  157. endwhile;
  158. //Pagination can go here if you want it.
  159. endif;
  160. ?>
  161.  
  162.  
  163. </div>
  164.  
  165. <?php else : ?> <?php endif; // if have_posts()
  166. wp_reset_query();
  167.  
  168. } // end foreach #tax_terms
  169. }
  170. ?>
  171.  
  172.  
  173. <p><a href="#top"> Back to top &uarr;</a></p>
  174.  
  175. </div><!-- #content -->
  176. </section><!-- #primary -->
  177.  
  178.  
  179.  
  180.  
  181.  
  182. <?php get_sidebar(); ?>
  183. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement