我在两个列中水平显示了20个主题类别的帖子,比如:

我使用的代码如下:
<?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 (have_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; ?>如果我点击帖子#1并移动到单个帖子显示页面,其中显示完整的帖子,并在页面的顶部/底部出现两个链接(下一篇文章,上一篇文章)。然后单击下一篇文章链接,它将显示文章#3。但我需要显示文章#2,然后显示文章#3,post#4...这是怎么可能的?
谢谢
发布于 2011-09-20 18:25:38
我会用css做到这一点。使用“标准”-Loop。例如
<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>使用<?php the_excerpt(); ?>你可以控制帖子的长度,wordpress的标准是55个单词。所以每个帖子都有55个单词的长度。
然后,您可以为每个.post元素赋予小于50%的宽度,并将其向左浮动。一个简单的例子:
#main-content {
float: left;
}
.post {
float: left;
width: 42%;
margin-right: 5%;
}现在你有两个列,你也可以让它响应,你的“上一个/下一个”链接也应该起作用。
下面是一个例子。David Hellmann
我希望这能对你有所帮助。欢迎光临!
https://stackoverflow.com/questions/7481358
复制相似问题