我有一页有三段摘录。只有第一节摘录被分配到后课堂,而不是第二节或第三节。我推测我的PHP中有问题:
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="100%" valign="top">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<p><?php the_time(\'F j, Y\'); ?> at <?php the_time(\'g:i a\'); ?> | <?php the_category(\', \'); ?> |
<?php comments_number(\'No comment\', \'1 comment\', \'% comments\'); ?></p>
</div>
<?php endwhile; else: ?>
<h2>Oops...</h2>
<p>Sorry, no posts we\'re found.</p>
<?php endif; ?>
<p align="center"><?php posts_nav_link(); ?></p>
</td>
</tr>
</table>
以下是生成的HTML:
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr>
<td width="100%" valign="top">
<div id="post-19" class="post-19 post type-post status-publish format-standard hentry category-printables">
<h2>
<a href="myurl"></a>
</h2>
<p></p>
<p></p>
</div>
<h2></h2>
<p></p>
<p></p>
<h2></h2>
<p></p>
<p></p>
<p align="center"></p>
</td>
</tr>
</tbody>
我如何确保post类应用于每一篇摘录,而不仅仅是第一篇?
最合适的回答,由SO网友:Wali Hassan 整理而成
Try this way
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="100%" valign="top">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<p><?php the_time(\'F j, Y\'); ?> at <?php the_time(\'g:i a\'); ?> | <?php the_category(\', \'); ?> |
<?php comments_number(\'No comment\', \'1 comment\', \'% comments\'); ?></p>
</div>
<?php endwhile; else: ?>
<h2>Oops...</h2>
<p>Sorry, no posts we\'re found.</p>
<?php endif; ?>
<p align="center"><?php posts_nav_link(); ?></p>
</td>
</tr>
</table>