Title: help with WP_Query code
Last modified: August 21, 2016

---

# help with WP_Query code

 *  [goldmember](https://wordpress.org/support/users/goldmember/)
 * (@goldmember)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/help-with-wp_query-code/)
 * on [this page](http://www.goldcoastchamber.com/) i have this code which pulls
   in the Upcoming Events category post titles:
 *     ```
       <h2>Gold Coast Chamber Upcoming Events</h2>
       Coming Soon...
       <?php
         $loop = new WP_Query( array(
           'category_name' => 'Events',
           'orderby' => 'meta_value',
           'meta_key' => 'eventdate',
           'order' => ASC)
         );
         while ( $loop->have_posts() ) : $loop->the_post(); ?>
         <div class="sing-event">
           <p class="up-events"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <div id="teaser"><img src="<?php $thumb = get_post_custom_values('teaser'); echo $thumb[0]; ?>" alt="<?php the_title(); ?>" /></div></div>
       <?php endwhile; ?>
       ```
   
 * We don’t have any posts from that category at the moment so I inserted the text“
   Coming Soon…” but i’m wondering how I could fit that Coming Soon… into the code
   so that it gets auto-generated when there’s no posts in that category.
 * any idea? please advise. thanks in advance!

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/help-with-wp_query-code/#post-3748520)
 * get inspired by the default loop structure:
 * [http://codex.wordpress.org/The_Loop_in_Action](http://codex.wordpress.org/The_Loop_in_Action)

Viewing 1 replies (of 1 total)

The topic ‘help with WP_Query code’ is closed to new replies.

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/help-with-wp_query-code/#post-3748520)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
