| a | b | |
|---|
| 0 | + | <?php get_header(); ?> |
|---|
| 0 | + | |
|---|
| 0 | + | <div id="main" class="clearfix"> |
|---|
| 0 | + | <div id="posts" class="grid_8"> |
|---|
| 0 | + | |
|---|
| 0 | + | <?php |
|---|
| 0 | + | // Global $wp_query so it's available to check for args |
|---|
| 0 | + | global $wp_query; |
|---|
| 0 | + | |
|---|
| 0 | + | $per_page = 10; |
|---|
| 0 | + | |
|---|
| 0 | + | // Add paging |
|---|
| 0 | + | $paged = ( get_query_var('paged') && get_query_var('paged') > 1 ) ? get_query_var('paged') : 1; |
|---|
| 0 | + | |
|---|
| 0 | + | // Your args |
|---|
| 0 | + | $custom_args = array( |
|---|
| 0 | + | 'posts_per_page' => $per_page, |
|---|
| 0 | + | 'paged' => $paged, |
|---|
| 0 | + | 'post__not_in' => get_option('sticky_posts'), |
|---|
| 0 | + | 'caller_get_posts'=>1, |
|---|
| 0 | + | ); |
|---|
| 0 | + | // Get the current query vars, if they exist |
|---|
| 0 | + | $args = array_filter( $wp_query->query_vars ); // The array filter removes 0, false, null values, etc |
|---|
| 0 | + | // If there were args, ie. a non empty array, merge them with the custom ones, else just use the custom ones |
|---|
| 0 | + | $args = ( $args && ( is_array( $args ) && !empty( $args ) ) ) ? array_merge( $custom_args , $args ) : $custom_args; |
|---|
| 0 | + | |
|---|
| 0 | + | // Put the args into the query |
|---|
| 0 | + | query_posts( $args ); |
|---|
| 0 | + | |
|---|
| 0 | + | // If the query has results, ie. posts |
|---|
| 0 | + | if( have_posts() ) : |
|---|
| 0 | + | $counter = 0; |
|---|
| 0 | + | |
|---|
| 0 | + | // While the query has posts |
|---|
| 0 | + | while( have_posts() ) : the_post(); |
|---|
| 0 | + | // Increase counter by one, so first is 1, second is 2, etc... |
|---|
| 0 | + | $counter++; |
|---|
| 0 | + | |
|---|
| 0 | + | // If the counter is less then 6, it's one of the first 5 posts |
|---|
| 0 | + | if( $counter < 6 ) : |
|---|
| 0 | + | ?> |
|---|
| 0 | + | <div class="post"> |
|---|
| 0 | + | <h1 class="post-title"><a href="<?php the_permalink(); ?>" title="Continue reading "<?php the_title(); ?>""><?php the_title(); ?></a></h1> |
|---|
| 0 | + | <div class="post-meta clearfix"> |
|---|
| 0 | + | <span>Posted: <abbr title="Posted at <?php the_time('H:i') ?> on <?php the_time('l, F j, Y'); ?>"><?php if(!function_exists('how_long_ago')){the_time('l, F j, Y'); } else { echo how_long_ago(get_the_time('U')); } ?></abbr></span> |
|---|
| 0 | + | <span>Category: <?php the_category(', ') ?></span> |
|---|
| 0 | + | <span>Comments: <?php comments_number('No Comment','1 Comment','% Comments'); ?></span> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | <div class="post-image"> |
|---|
| 0 | + | <?php if( get_post_meta( $post->ID, "image", true ) ) : ?> |
|---|
| 0 | + | <img src="<?php bloginfo( 'template_directory' ); ?>/timthumb.php?src=<?php echo get_post_meta( $post->ID, "image", true ); ?>&w=576&zc=1&q=90" border="0" alt="<?php the_title(); ?>" /> |
|---|
| 0 | + | <?php else : ?> |
|---|
| 0 | + | <?php endif; ?> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | <div class="post-excerpt"><?php the_content('<span class="post-link">Continue reading »</span>'); ?></div> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | <?php |
|---|
| 0 | + | // Else the counter is more then 5, so it's one of the 15 following posts |
|---|
| 0 | + | else : |
|---|
| 0 | + | ?> |
|---|
| 0 | + | |
|---|
| 0 | + | <div class="post-small"> |
|---|
| 0 | + | |
|---|
| 0 | + | <?php the_date('', '<br />', '<hr />'); ?> |
|---|
| 0 | + | |
|---|
| 0 | + | <h1 class="post-title-small"><a href="<?php the_permalink(); ?>" title="Continue reading "<?php the_title(); ?>""><?php the_title(); ?></a></h1> |
|---|
| 0 | + | <div class="post-meta clearfix"> |
|---|
| 0 | + | <span>Posted: <abbr title="Posted at <?php the_time('H:i') ?> on <?php the_time('l, F j, Y'); ?>"><?php if(!function_exists('how_long_ago')){the_time('l, F j, Y'); } else { echo how_long_ago(get_the_time('U')); } ?></abbr></span> |
|---|
| 0 | + | <span>Category: <?php the_category(', ') ?></span> |
|---|
| 0 | + | <span>Comments: <?php comments_number('No Comment','1 Comment','% Comments'); ?></span> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | |
|---|
| 0 | + | </div> |
|---|
| 0 | + | |
|---|
| 0 | + | <?php |
|---|
| 0 | + | // End if counter check |
|---|
| 0 | + | endif; |
|---|
| 0 | + | // End post loop |
|---|
| 0 | + | endwhile; |
|---|
| 0 | + | // End if have posts check |
|---|
| 0 | + | endif; |
|---|
| 0 | + | ?> |
|---|
| 0 | + | <div class="post-navigation clearfix"><?php if(function_exists('wp_pagenavi')) wp_pagenavi(); ?></div> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | <div id="sidebar" class="grid_4"> |
|---|
| 0 | + | <?php get_sidebar(); ?> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | </div> |
|---|
| 0 | + | <?php get_footer(); ?> |
|---|
| ... | |
|---|