嘿,我正在尝试自定义我的WordPress帖子循环,为一组特定的帖子创建不同的帖子样式。
例如,前三篇文章将以自己的方式设计风格,接下来的四篇文章将以自己的方式设计风格,等等。
此外,我想在一定数量的帖子之后增加一个休息时间。请参见下图,了解我正在努力实现的目标。
http://cdn.ratedrnb.com/2016/04/photo.png
下面的代码就是我用来改变帖子风格的代码。
<?php if (have_posts()) :
$count = 0;
// What page are we on?
$paged = ( get_query_var(\'paged\') > 1 ) ? get_query_var(\'paged\') : 1;
// How many pages of posts do we have to display?
//$max = $wp_query->max_num_pages;
while (have_posts()) : the_post();
$count++;
if ($count == 1 && $paged == 1) : ?>
<!--first post -->
**html/style of the first post**
<!--next four post -->
<?php elseif ($count > 1 && $count <5 && $paged == 1) : ?>
**html/style of next four post**
<!-- 4th post and break div -->
<?php elseif ($count == 5 && $paged == 1) : ?>
**html/style of fourth post**
<div>This is the div break</div>
<!--next five post -->
<?php elseif ($count >5 && $count < 11 && $paged == 1) : ?>
**html/style of next six post**
<!--sixth post and div break-->
<?php elseif ($count == 11 && $paged == 1) : ?>
**html/style of 6th post**
<div>This is the div break</div>
<!--last eight post-->
<?php elseif ($count > 12 && $count < 21 && || $paged == 1) : ?>
**html/style of last eight post**
<?php endif;
endwhile;
endif; ?>
现在,这段代码的设计也使得当我转到下一页时,其余的页面采用最后八篇文章的样式。
有人能告诉我如何更改下面的这些行,以显示前3篇文章,而不是仅显示一篇。
<?php if (have_posts()) :
$count = 0;
// What page are we on?
$paged = ( get_query_var(\'paged\') > 1 ) ? get_query_var(\'paged\') : 1;
// How many pages of posts do we have to display?
//$max = $wp_query->max_num_pages;
while (have_posts()) : the_post();
$count++;
if ($count == 1 && $paged == 1) : ?>
还有谁能向我解释一下,为什么我雇来做这件事的人必须像下面这样分离循环。
<!--next four post -->
<?php elseif ($count > 1 && $count <5 && $paged == 1) : ?>
**html/style of next four post**
<!-- 4th post and break div -->
<?php elseif ($count == 5 && $paged == 1) : ?>
**html/style of fourth post**
<div>This is the div break</div>
我正试图对PHP编码有更多的了解。