Advertisement
iselaespana

grid-loop

Feb 2nd, 2012
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. <?php
  2. /**
  3. * The loop to show posts in columns
  4. *
  5. * loop-grid.php
  6.  
  7. * @package WordPress
  8. * @subpackage Twenty Ten
  9. * @since 3.0.0
  10. */
  11. ?>
  12.  
  13. <?php /* Display navigation to next/previous pages when applicable */ ?>
  14.  
  15. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  16. <div id="nav-above" class="navigation">
  17.  
  18. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  19. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  20.  
  21.  
  22. </div><!-- #nav-above -->
  23. <?php endif; ?>
  24.  
  25. <?php /* If there are no posts to display, such as an empty archive page */ ?>
  26. <?php if ( ! have_posts() ) : ?>
  27. <div id="post-0" class="post error404 not-found">
  28. <h1 class="entry-title"><?php _e( 'Not Found', 'twentyten' ); ?></h1>
  29. <div class="entry-content">
  30. <p><?php _e( 'Apologies, but no results were found for the requested Archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
  31. <?php get_search_form(); ?>
  32. </div><!-- .entry-content -->
  33. </div><!-- #post-0 -->
  34. <?php endif; ?>
  35. <?php if ( function_exists( 'meteor_slideshow' ) ) { meteor_slideshow(); } ?>
  36.  
  37. <?php /* Start the Loop */ ?>
  38.  
  39.  
  40. <?php
  41. $num_cols = 3; // set the number of columns here
  42. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // for pagination
  43. $args = array(
  44. 'posts_per_page' => 6, // optional to overwrite the dashboard setting
  45. 'cat' => 0, // add any other query parameter to this array
  46. 'paged' => $paged
  47. );
  48.  
  49. for ( $i=1 ; $i <= $num_cols; $i++ ) :
  50. echo '<div id="col-' . $i . '" class="col" >';
  51. $counter = $num_cols + 1 - $i; ?>
  52.  
  53. <?php while (have_posts()) : the_post();
  54. if( $counter%$num_cols == 0 ) :
  55. // begin of core posts output ?>
  56.  
  57.  
  58. <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  59. <div class="post-thumb">
  60.  
  61. <?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
  62. </div>
  63.  
  64. <div class="entry-meta">
  65. <?php
  66. printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
  67. get_permalink(),
  68. esc_attr( get_the_time() ),
  69. get_the_date(),
  70. get_author_posts_url( get_the_author_meta( 'ID' ) ),
  71. sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
  72. get_the_author()
  73. );
  74. ?><span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  75. </div><!-- .entry-meta -->
  76.  
  77. <div class="entry-summary">
  78. <?php the_excerpt(); ?>
  79. </div><!-- .entry-summary -->
  80.  
  81. <div class="entry-utility">
  82. <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'twentyten' ); ?></span><?php the_category( ', ' ); ?></span>
  83. <span class="meta-sep"> | </span>
  84. <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __( 'Tagged ', 'twentyten' ) . '</span>', ', ', '<span class="meta-sep"> | </span>' ); ?>
  85. <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
  86. <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
  87. </div><!-- #entry-utility -->
  88. </div><!-- #post-<?php the_ID(); ?> -->
  89. <?php // global $withcomments; $withcomments = 1;
  90. //comments_template( '', true ); ?>
  91.  
  92. <?php //end of posts output
  93.  
  94. endif; $counter++;
  95. endwhile;
  96. rewind_posts();
  97. echo '</div>'; //closes the column div
  98. endfor; ?>
  99.  
  100. <?php /* Display navigation to next/previous pages when applicable */ ?>
  101. <?php if ( $wp_query->max_num_pages > 1 ) : ?>
  102. <div id="nav-below" class="navigation">
  103. <?php if(function_exists('page_navi')) { page_navi(); } else { ?>
  104. <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
  105. <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
  106. <?php } ?>
  107. </div><!-- #nav-below -->
  108. <?php endif;
  109. wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement