2013-09-21 123 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

我错过了几个结束标签,这就是为什么你在哪里得到这个错误。我编辑了代码,以便您可以使用它。是的,把它放在你的索引文件中应该显示文章。 –

相关问题