我想回圈<div >使用while (have_posts()) : the_post();> 問題是這個回圈<div >在第一個內部創建另一個<div >,我失去了創建 2 列部分。下面是我的代碼
得到這個輸出:
<div class="col-md-6">
<div class="col-md-6">
Post 1 details
</div>
<div class="col-md-6">
Post 2 details
</div>
</div>
我想得到這個輸出:
<div class="col-md-6">
Post 1 details
</div>
<div class="col-md-6">
Post 2 details
</div>
<section class="post-section">
<div class="container">
<div class="row">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="col-md-6">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<div class="entry">
<?php the_content(); ?>
</div>
<?php endwhile;
else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
</div>
</div>
</section>
uj5u.com熱心網友回復:
您關閉<div >回圈部分的外部。您的固定代碼是:
<section class="post-section">
<div class="container">
<div class="row">
<?php if (have_posts()) : ?>
<?php while (have_posts()) :
the_post(); ?>
<div class="col-md-6">
<h2><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile;
else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
</div>
</div>
</section>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/429046.html
標籤:WordPress wordpress 主题 自定义 wordpress 页面
