help with WP_Query code (2 posts)

  1. goldmember
    Posted 3 years ago #

    on this page i have this code which pulls in the Upcoming Events category post titles:

    <h2>Gold Coast Chamber Upcoming Events</h2>
    Coming Soon...
      $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!

  2. Michael
    Forum Moderator
    Posted 3 years ago #

    get inspired by the default loop structure:


Topic Closed

This topic has been closed to new replies.

About this Topic