Advertisement
Guest User

Untitled

a guest
Mar 8th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Gallery
  4. */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8. <div id="post">
  9.  
  10.  
  11. <ul class="filter clearfix">
  12. <li><strong>Фильтр:</strong></li>
  13. <li class="active"><a href="javascript:void(0)" class="all">Все</a></li>
  14.  
  15. <?php
  16. // Get the taxonomy
  17. $terms = get_terms('filter', $args);
  18.  
  19. // set a count to the amount of categories in our taxonomy
  20. $count = count($terms);
  21.  
  22. // set a count value to 0
  23. $i=0;
  24.  
  25. // test if the count has any categories
  26. if ($count > 0) {
  27.  
  28. // break each of the categories into individual elements
  29. foreach ($terms as $term) {
  30.  
  31. // increase the count by 1
  32. $i++;
  33.  
  34. // rewrite the output for each category
  35. $term_list .= '<li><a href="javascript:void(0)" class="'. $term->slug .'">' . $term->name . '</a></li>';
  36.  
  37. // if count is equal to i then output blank
  38. if ($count != $i)
  39. {
  40. $term_list .= '';
  41. }
  42. else
  43. {
  44. $term_list .= '';
  45. }
  46. }
  47.  
  48. // print out each of the categories in our new format
  49. echo $term_list;
  50. }
  51. ?>
  52. </ul>
  53.  
  54.  
  55. <ul class="filterable-grid clearfix">
  56.  
  57. <?php
  58. // Set the page to be pagination
  59. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  60.  
  61. // Query Out Database
  62. $wpbp = new WP_Query(array( 'post_type' => 'portfolio', 'posts_per_page' => '8', 'paged' => $paged ) );
  63. ?>
  64.  
  65. <?php
  66. // Begin The Loop
  67. if ($wpbp->have_posts()) : while ($wpbp->have_posts()) : $wpbp->the_post();
  68. ?>
  69.  
  70. <?php
  71. // Get The Taxonomy 'Filter' Categories
  72. $terms = get_the_terms( get_the_ID(), 'filter' );
  73. ?>
  74.  
  75. <?php
  76. $large_image = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'fullsize', false, '' );
  77. $large_image = $large_image[0];
  78. ?>
  79.  
  80. <?php
  81. //Apply a data-id for unique indentity,
  82. //and loop through the taxonomy and assign the terms to the portfolio item to a data-type,
  83. // which will be referenced when writing our Quicksand Script
  84. ?>
  85. <li data-id="id-<?php echo $count; ?>" data-type="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
  86.  
  87. <?php
  88. // Check if wordpress supports featured images, and if so output the thumbnail
  89. if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :
  90. ?>
  91.  
  92. <?php // Output the featured image ?>
  93. <a rel="prettyPhoto[gallery]" href="<?php echo $large_image ?>"><?php the_post_thumbnail('portfolio'); ?></a>
  94.  
  95. <?php endif; ?>
  96.  
  97. <?php // Output the title of each portfolio item ?>
  98. <p><a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></p>
  99.  
  100. </li>
  101.  
  102.  
  103. <?php $count++; // Increase the count by 1 ?>
  104. <?php endwhile; endif; // END the Wordpress Loop ?>
  105. <?php wp_reset_query(); // Reset the Query Loop?>
  106.  
  107. </ul>
  108.  
  109.  
  110. <?php
  111. /*
  112. * Download WP_PageNavi Plugin at: http://wordpress.org/extend/plugins/wp-pagenavi/
  113. * Page Navigation Will Appear If Plugin Installed or Fall Back To Default Pagination
  114. */
  115. if(function_exists('wp_pagenavi'))
  116. {
  117. wp_pagenavi(array( 'query' => $wpbp ) );
  118. wp_reset_postdata(); // avoid errors further down the page
  119. }
  120. ?>
  121.  
  122. </div><!-- /post -->
  123. </div><!-- /main -->
  124.  
  125. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement