我看了看,並試圖找到我一直在尋找的答案,但我還沒有看到答案爲此:循環設置Wordpress中的帖子數,然後在下一組再次運行相同的循環,等等
我正在嘗試生成一個Wordpress循環,它從一個類別中獲取所有帖子,並在<li></li>
標籤內一次顯示三個帖子。
輸出應該是這樣的:
<li>My post title | Another Title | Third title</li>
<li>The next post title | A different post | Post #6</li>
<li>And so on | And so forth</li>
我該類別中的所有條目直到完成需要這個循環,然後退出循環。
我的代碼在這一點上完全不工作,但我已經提供了我正在處理的內容。如果有人有任何解決辦法,我很樂意爲你提供瘋狂的道具,因爲這給我三天沒有任何解決方案。
<?php // Loop through posts three at a time
$recoffsetinit = '0';
$recoffset = '3';
query_posts('cat=1&showposts=0');
$post = get_posts('category=1&numberposts=3&offset='.$recoffsetinit.');
while (have_posts()) : the_post();
?>
<li>
<?php
$postslist = get_posts('cat=1&order=ASC&orderby=title');
foreach ($postslist as $post) : setup_postdata($post);
static $count = 0; if ($count == "3") { break; } else { ?>
<a href="<?php the_permalink() ?>"></a>
<?php $count++; } ?>
<?php endforeach; ?>
<?php $recoffsetinit = $recoffset + $recoffsetinit; ?>
</li>
<?php endwhile; ?>