这个else
在PHP中,在if
语句结束括号,请查看以下内容:
if( 1 == 1 ) {
echo \'true!\';
}
else {
echo \'false.\';
}
因此,您的代码如下所示:
<?php
$posts = get_posts(array(
\'post_type\' => \'retail_units\',
\'orderby\' => \'date\',
\'order\' => \'ASC\'
));
if( ! empty( $posts ) ) {
foreach( $posts as $post ) { setup_postdata( $post );
?>
<li>
<a href="<?php the_permalink();?>"><?php the_title(); ?></a>
</li>
<div style="clear:both;"></div>
<?php
}
wp_reset_postdata();
} else {
?>
<li>No Posts Found.</li>
<?php } ?>