我使用此代碼來顯示具有特定類的div的WordPress帖子。有沒有辦法以隨機順序獲得帖子,仍然這樣做?我搜索了,找不到任何幫助我弄清楚的東西。謝謝。
<?php $count = 0; if (have_posts()) : while(have_posts()) : the_post() ?>
<div class="grid4 noall
<?php if($count%3 == 0) { echo 'first'; }; if($count%3 == 1) { echo 'mid'; }; if($count%3 == 2) { echo 'last'; }; $count++; ?>">
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<a class="plink" href="<?php the_permalink() ?>" rel="bookmark" title=" <?php the_title_attribute(); ?>">
<section class="portfolio-wrapper">
<?php the_post_thumbnail('thumb-800'); ?>
<div class="portfolio-title">
<h3 class="portfolio-header"><?php the_title(); ?></h3>
<?php if(get_field('portfolio_subtitle')): ?>
<h5 class="portfolio-category">
<?php the_field('portfolio_subtitle'); ?>
</h5>
<?php endif; ?>
</div>
</section>
</a>
</article>
</div>
<?php endwhile; ?>
你能在這裏顯示整個循環,所以我可以看到你當前的查詢? – Fencer04
我更新了代碼 – Lonnie