Trouble adding an Else Statement
-
I’m having trouble adding an Else to this loop. It won’t validate π
<?php //if a certain page, then display posts authored by the logged in user global $current_user; get_currentuserinfo(); echo 'User ID: ' . $current_user->ID . "\n"; $args=array( 'author' => $current_user->ID, 'post_type' => 'wpbdp_listing', ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <h1> <a href="/therapist-directory/?action=editlisting&listing_id=<?php the_ID(); ?> ">Edit Your Profile</a> !</h1> <?php endwhile; else: ?> <p>Sorry, no posts matched your criteria.</p> <!-- REALLY stop The Loop. --> <?php endif; ?>
The topic ‘Trouble adding an Else Statement’ is closed to new replies.