我正在嘗試將 wordpress 內容拉到使用 Bootstrap 創建的網格結構中。但我不想為每一列創建單獨的查詢。如何在單個查詢中從同一類別中提取內容?我的代碼如下。我想顯示最后添加的 3 項
<div class="container">
<?php query_posts('showposts=3&orderby=date&cat=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<div class="row">
<div class="col-8">
<img src="" class="img-fluid rounded" alt="...">
</div>
<div class="col-4">
<img src="" class="img-fluid mb-3 rounded" alt="...">
<img src="" class="img-fluid rounded" alt="...">
</div>
</div>
<?php endwhile; ?>
</div>
我想做的事
uj5u.com熱心網友回復:
<div class="container">
<div class="row">
<?php $i = 1; query_posts('showposts=3&orderby=date&cat=1'); ?>
<div class="col-8">
<?php while (have_posts()) : the_post(); ?>
<?php if($i==1){ ?>
<img src="" class="img-fluid rounded" alt="...">
</div>
<div class="col-4">
<?php } elseif($i==2){ ?>
<img src="" class="img-fluid mb-3 rounded" alt="...">
<?php } else { ?>
<img src="" class="img-fluid rounded" alt="...">
<?php } $i ; endwhile; ?>
</div>
</div>
</div>
uj5u.com熱心網友回復:
點擊圖片查看問題
否則造成了問題。右欄中的2個內容也是相同的。我希望它與眾不同。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/467920.html
