Get 10 posts at main and 10 older at sidebar
-
I’m trying to make a template and I’d like to show the first 10 posts at the main column and the show the 10 older at the sidebar. At the main, I have:
<?php if ( have_posts() ) : ?> <div class="content"> <?php while ( have_posts() ) : the_post(); ?> <div class="article list"> <a href="<?php the_permalink(); ?>"><img src="<?=catch_that_image(); ?>"></a> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="caption"><span class="date"><?php the_time('j F, Y'); ?></span> | <a href="<?php the_permalink(); ?>#comments"> <?php comments_number('No comments', '1 comment', '% comments'); ?> </a> </div> <div class="txt"> <?php the_excerpt(); ?> </div> </div> <?php endwhile; ?> </div> <?php endif; ?>
And at the sidebar I have:
<?php if ( have_posts() ) : ?> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $offset = ($paged * get_option('posts_per_page')); $args = array ( 'paged' =>$paged, 'posts_per_page' => get_option('posts_per_page'), 'offset' => $offset ); get_posts($args); ?> <?php while ( have_posts() ) : the_post(); ?> <div class="article"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <div class="caption"><span class="date"><?php the_time('j F, Y'); ?></span> | <a href="<?php the_permalink(); ?>#comments"> <?php comments_number('No comments', '1 comment', '% comments'); ?> </a> </div> <div class="txt"> <?php the_excerpt(); ?> </div> </div> <?php endwhile; ?> <?php endif; ?>
Does anybody what I’m making wrong? Thank you!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get 10 posts at main and 10 older at sidebar’ is closed to new replies.