Post navigation in wordpress twenty ten theme
I am horizontally displaying twenty ten theme category posts in two columns like:
I am using below code:
<?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) :
$wp_query->next_post(); else : the_post(); ?>
<div id="left-column">
<h1><?php the_permalink(); ?></h1>
<?php the_content(); ?>
</div>
<?php endif; endwhile; else: ?>
<?php endif; ?>
<?php $i = 0; rewind_posts(); ?>
<?php if (ha开发者_如何学JAVAve_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?>
<div id="right-column">
<h1><?php the_permalink(); ?></h1>
<?php the_content(); ?>
</div>
<?php endif; endwhile; else: ?>
<?php endif; ?>
If i click on post #1 and move to single post display page, where full post displays and two links appears(next post,previous post) at top/bottom of the page. and then click on next post link it goes to display post #3. But i need to display post #2 then post #3, post#4.... how it is possible.?
Thanks
I would do this with css. Use the "standard"-Loop. For example
<div id="main-content">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="post">
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
</div>
With <?php the_excerpt(); ?>
you can control the length of the post, wordpress standard is 55 Words. So every post has a length of 55 Words.
Then you can give each .post element a width less then 50% and float it left. An simple example:
#main-content {
float: left;
}
.post {
float: left;
width: 42%;
margin-right: 5%;
}
Now u are having two columns and you can make it responsive too and your "previous/next" links should work too.
Here is an example. David Hellmann
I hope, this can help you. Greetings!
精彩评论