Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ADAPTED from my post: http://www.transformationpowertools.com/wordpress/playing-with-columns-stacking-posts-grid-style
- TWO FULL WIDTH POSTS, AD BLOCK, TWO COLUMNS OF POSTS
- <?php $do_not_duplicate = array();
- global $query_string;
- query_posts( $query_string . '&posts_per_page=2' );
- while (have_posts()) : the_post(); ?>
- <?php //FULL WIDTH POSTS ?>
- <div class="news_item_a" id="post-<?php the_ID(); ?>">
- <h2 class="contentheading"> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2>
- <div class="newsitem_tools">
- <div class="newsitem_info">
- <span class="createdate"> <?php the_time('j F Y, h:m') ?> </span> <span class="createby"> <?php the_author() ?> </span>
- </div>
- <!-- end of info-->
- </div>
- <!-- end of tools-->
- <div class="newsitem_text">
- <div class="news_item_article">
- <img class="thumb" src="<?php echo catch_that_image() ?>" border="0" alt="<?php the_title(); ?>" />
- <?php the_excerpt(); ?>
- <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); // for multi page posts ?>
- <p><a rel="nofollow" class="readon" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><span style="display: none;"><?php the_title(); ?></span></a></p>
- </div>
- </div>
- <span class="article_separator"> </span>
- </div>
- <?php // END OF FULL WIDTH POST ?>
- <?php $do_not_duplicate[] = $post->ID;
- endwhile; ?>
- <!--ADVERTISING BLOCK HERE-->
- <h2>ADVERTISING</h2>
- <?php //TWO COLUMN POSTS START// ?>
- <?php
- global $query_string;
- parse_str( $query_string, $args );
- $args['post__not_in'] = $do_not_duplicate;
- $args['posts_per_page'] = -1;
- query_posts( $args );
- ?>
- <?php $num_cols = 2; // set the number of columns here
- for ( $i=1 ; $i <= $num_cols; $i++ ) : ?>
- <div id="post-column-<?php echo $i; ?>" class="post-column">
- <?php $counter = $num_cols + 1 - $i;
- while (have_posts()) : the_post();
- if( $counter%$num_cols == 0 ) : ?>
- <div class="news_item_a column<?php echo $i; ?>" id="post-<?php the_ID(); ?>">
- <h2 class="contentheading"> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> </h2>
- <div class="newsitem_tools">
- <div class="newsitem_info">
- <span class="createdate"> <?php the_time('j F Y, h:m') ?> </span> <span class="createby"> <?php the_author() ?> </span>
- </div>
- <!-- end of info-->
- </div>
- <!-- end of tools-->
- <div class="newsitem_text">
- <div class="news_item_article">
- <img class="thumb" src="<?php echo catch_that_image() ?>" border="0" alt="<?php the_title(); ?>" />
- <?php the_excerpt(); ?>
- <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); // for multi page posts ?>
- <p><a rel="nofollow" class="readon" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><span style="display: none;"><?php the_title(); ?></span></a></p>
- </div>
- </div>
- <span class="article_separator"> </span>
- </div>
- <?php endif; $counter++;
- endwhile;
- rewind_posts(); ?>
- </div> <!--closes the .post-column div-->
- <?php endfor; ?>
- CSS for the above
- .post-column { float: left; width: 49%; margin-left: 1%; }
- #post-column-1 { margin-left: 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement