2013-09-21 37 views
-1

我正在建設一個網站(與Wordpress 3.6),並希望把新聞/文章安排如下:WordPress的:第一篇文章,專欄;其他文章,2列

- 第一篇文章是最大的大小(一列);

- 以下文章分爲兩列。

每頁僅顯示5或7篇文章。有人可以幫我做到這一點?請!

問候,

+0

多帖子,在這裏回答:http://wordpress.stackexchange.com/questions/115128/first-article-single-column-other-articles-2-columns – fuxia

+0

謝謝toscho! :) –

回答

0

這裏是做以下循環:

查詢最新7個帖子在第一列

顯示器的第一篇文章

其餘兩個6的div相同類,你可以風格來形成列

<?php 
$count = 1; // this is the variable that will count how many posts have been shown 
$my_query = new WP_Query('posts_per_page=7'); 
if ($my_query->have_posts()) : while($my_query->have_post()) : $my_query->the_post(); 
    if($count == 1) { // this is the output for the first post 
    ?> 
    <div id="full-post"> 
    // post contents 
    </div><!-- end .full-post --> 

<?php $count++; // here we increment the counter 
} elseif ($count == 2 || $count == 5) { ?> 
    <div class="column"> // notice that only on 2nd and 5th iteration we are only opening the column div 
     <div class="post-container"> 
      // post contents 
     </div><!-- end .post-container --> 
    <?php count++; ?> 
} elseif ($count == 4 || $count == 7) { ?> 
    <div class="post-container"> 
    //post contents 
    </div><!-- end post.container --> 
    </div><!-- end .column --> // here we are closing the column div 
    <?php $count++; 
} else { ?>//these are just normal posts 
    <div class="post-container"> 
    //post contents 
    </div><!-- end post.container --> 
    <?php $count++; 
} 
endwhile; 
endif; 
?> 
+0

嗨!我在這個世界上「新」!我把這個放在哪裏? –

+0

我已經將它添加到index.php並說出來了:「解析錯誤:語法錯誤,在E:\ wordpress \ wp-content \ themes \ Ourique \ index.php中出現意外的'<'第25行」... Can You爲我解釋更好嗎? –

+0

我錯過了幾個結束標籤,這就是爲什麼你在哪裏得到這個錯誤。我編輯了代碼,以便您可以使用它。是的,把它放在你的索引文件中應該顯示文章。 –

相關問題