Advertisement
Guest User

Untitled

a guest
Mar 5th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <?php
  2.  
  3. get_header(); ?>
  4.  
  5. <section id="primary">
  6. <div id="content" role="main">
  7.  
  8. <?php if ( have_posts() ) : ?>
  9.  
  10. <header class="page-header">
  11. <h1 class="page-title"><?php
  12. printf( __( 'Category Archives: %s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' );
  13. ?></h1>
  14.  
  15. <?php
  16. $category_description = category_description();
  17. if ( ! empty( $category_description ) )
  18. echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' );
  19. ?>
  20. </header>
  21.  
  22. <?php twentyeleven_content_nav( 'nav-below' ); ?>
  23.  
  24. <?php /* Start the Loop */ ?>
  25.  
  26. <?php function catch_that_image() {
  27. global $post, $posts;
  28. $first_img = '';
  29. ob_start();
  30. ob_end_clean();
  31. $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  32. $first_img = $matches [1] [0];
  33.  
  34. if(empty($first_img)){ //Defines a default image
  35. $first_img = "/images/default.jpg";
  36. }
  37.  
  38. return $first_img;
  39. } ?>
  40.  
  41.  
  42. <table>
  43. <tr>
  44. <?php $colCount = 0; $rowCount = 0; $columnLimit = 3; $rowLimit = 1; ?>
  45. <?php while ( have_posts() ) : the_post(); ?>
  46. <?php if(function_exists('wp_page_numbers')) : wp_page_numbers(); endif; ?>
  47.  
  48. <?php if($colCount == 0){echo '<tr>'; $rowCount++;} ?>
  49.  
  50.  
  51. <td>
  52. <a href = "<?php the_permalink() ?>">
  53. <img src="<?php echo catch_that_image(); ?>" style="width:150px;height:autopx;padding:25px 30px 5px 30px;vertical-align: middle;"/>
  54. </a>
  55. <a class="more-link" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><center><?php the_title_attribute(); ?></center></a>
  56. </td>
  57.  
  58. <?php $colCount++; if($colCount >= $columnLimit){ echo '</tr>'; $colCount = 0; if($rowCount >= $rowLimit){break;}} ?>
  59.  
  60.  
  61.  
  62.  
  63. <?php endwhile; ?>
  64.  
  65. </tr>
  66. </table>
  67.  
  68. <?php twentyeleven_content_nav( 'nav-below' ); ?>
  69.  
  70. <?php else : ?>
  71.  
  72. <article id="post-0" class="post no-results not-found">
  73. <header class="entry-header">
  74. <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
  75. </header><!-- .entry-header -->
  76.  
  77. <div class="entry-content">
  78. <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
  79. <?php get_search_form(); ?>
  80. </div><!-- .entry-content -->
  81. </article><!-- #post-0 -->
  82.  
  83. <?php endif; ?>
  84.  
  85. </div><!-- #content -->
  86. </section><!-- #primary -->
  87.  
  88. <?php get_sidebar(); ?>
  89. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement