Custom loop default text if no posts
-
I have a page (careers) that I use with a custom loop to display any positions coming up. One problem I am having is if there is no positions I would like it to display:
“There are no job openings at this time.”
For some reason I can’t get the default text to display if there are no positions.
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; endif; ?> <hr> <?php p_reset_postdata(); $args = array( 'category_name' => 'careers' ); $the_query = new WP_Query( $args ); //wp_reset_postdata(); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <h3><a href="<?php the_permalink(); ?>"><?php the_title() ;?></a></h3> <?php the_excerpt(); ?> <hr> <?php endwhile; else: ?> <p>There are no job openings at this time.</p> <?php endif; ?>
Here is the page in question:
Careers page in question
Any help would be greatly appreciated.Vince
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom loop default text if no posts’ is closed to new replies.