2011-09-20 71 views
1

我水平在兩列中顯示20級10的主題類別的職位,如:文章導航

enter image description here

我使用下面的代碼:

<?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,帖子#4 ....怎麼可能。?

謝謝

回答

2

我會這樣做與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%; 
} 

現在u的有兩列,你可以把它響應也和你的「上一個/下一個」鏈接應該工作了。

這裏是一個例子。 David Hellmann

我希望這可以幫助你。 問候!

+0

嗨馬庫斯,非常感謝它的作品。 –

+0

沒問題,交配。我很高興能夠提供幫助。 –