The else
in PHP goes at the end of the if
statements closing bracket, look at the following:
if( 1 == 1 ) {
echo 'true!';
}
else {
echo 'false.';
}
So you code would look something like this:
<?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="https://wordpress.stackexchange.com/questions/168269/<?php the_permalink();?>"><?php the_title(); ?></a>
</li>
<div style="clear:both;"></div>
<?php
}
wp_reset_postdata();
} else {
?>
<li>No Posts Found.</li>
<?php } ?>