Advertisement
Guest User

link to the first post of the category

a guest
Jan 16th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3.  
  4. <script type="text/javascript" src="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js"></script>
  5. <script type="text/javascript" src="http://cherne.net/brian/resources/jquery.hoverIntent.js"></script>
  6. <script type="text/javascript">
  7. $(document).ready(function () {
  8.  
  9. var config = {
  10. over: hideGrid, // function = onMouseOver callback (REQUIRED)
  11. timeout: 0, // number = milliseconds delay before onMouseOut
  12. out: showGrid, // function = onMouseOut callback (REQUIRED)
  13. interval: 100
  14. };
  15.  
  16. $(".left-side").hover( hideGrid, showGrid );
  17. $(".right-side").hover( hideGrid, showGrid );
  18.  
  19. function hideGrid() {
  20. $(this).find('div.overlay-grid').animate({opacity: '0'}, 300, 'easeOutExpo', function() { /* Animation complete. */});
  21. $(this).find('div.category-copy h2').css('color', '#508ba9');
  22. $(this).find('div.amount').css('background', 'rgba(255, 255, 255, 1)');
  23. }
  24. function showGrid() {
  25. $(this).find('div.overlay-grid').animate({opacity: '1'}, 300, 'easeOutExpo', function() { /* Animation complete. */});
  26. $(this).find('div.category-copy h2').css('color', '#666');
  27. $(this).find('div.amount').css('background', 'rgba(255, 255, 255, 0.6)');
  28. }
  29.  
  30. });
  31. </script>
  32. <div class="centeredContent">
  33.  
  34. <section id="main">
  35. <?php include (TEMPLATEPATH . '/inc/breadcrumb.php' ); ?>
  36.  
  37. <header id="categoryHeader">
  38. <hgroup>
  39. <h2>Pattern <span class="outlineHeader">Categories</span></h2>
  40. <h3>Categories</h3>
  41. </hgroup>
  42. </header>
  43. <?php
  44. $counter = 0;
  45. $args=array(
  46. 'orderby' => 'name',
  47. 'order' => 'ASC',
  48. 'taxonomy' => 'pattern-categories'
  49. );
  50. $categories=get_categories($args);
  51. echo '<div id="categories-container"><ul>';
  52. foreach($categories as $category) {
  53. $args = array(
  54. 'category__in' => array($category->term_id),
  55. 'posts_per_page' => 1
  56. );
  57. $first_cat_post = get_posts($args);
  58.  
  59. if($counter%2 == 0){
  60. echo '<a href="'.get_permalink( $first_cat_post[0]->ID ) .'" title="View first post from category: '.esc_attr( $category->name ).'" style="text-decoration:none;">
  61. <li class="left-side">
  62. <div class="category-thumb">
  63. <div class="thumb"><img src="'.site_url().'/wp-content/images/category-thumbs/'.$category->slug.'.jpg" alt="'.$category->name.'"></div>
  64. <div class="overlay-grid">&nbsp;</div>
  65. <div class="amount">'.$category->count.'</div>
  66. </div>
  67. <div class="category-copy">
  68. <h2>'.$category->name.'</h2>
  69. <p>'.$category->description.'</p>
  70. </div>
  71. </li>
  72. </a>';
  73. }else{
  74. echo '<a href="'.get_permalink( $first_cat_post[0]->ID ) .'" title="View first post from category: '.esc_attr( $category->name ).'" style="text-decoration:none;">
  75. <li class="right-side">
  76. <div class="category-thumb">
  77. <div class="thumb"><img src="'.site_url().'/wp-content/images/category-thumbs/'.$category->slug.'.jpg" alt="'.$category->name.'"></div>
  78. <div class="overlay-grid">&nbsp;</div>
  79. <div class="amount">'.$category->count.'</div>
  80. </div>
  81. <div class="category-copy">
  82. <h2>'.$category->name.'</h2>
  83. <p>'.$category->description.'</p>
  84. </div>
  85. </li>
  86. </a>';
  87. }
  88. $counter +=1;
  89. }
  90. ?>
  91. </ul>
  92. </div>
  93. </section>
  94. </section>
  95. </div> <!-- "main" section centered content ENDS -->
  96. </div> <!-- END CENTERED CONTENT-->
  97.  
  98. <?php get_footer(); ?>
  99. <?php/**/?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement