Multi query array()
-
I am working on a site which lists models.
For every model I create a page, which have several custom fields, one of them is dob for the date of birth.
This value is defined as mm/dd/yyyy.I want to create a query which retrieves all the pages where the dob mm/dd/yyyy gets stripped to mm/dd and then compared to the current date to see if it is today.
I use the following code/query. There’s 1 disadvantage; when there are 0 results the header and
still shows.
Anybody have a tip ?
$args = array( 'post_type' => 'page', 'post_parent' => '2', 'orderby' => 'title', 'order' => 'ASC', 'showposts' => '-1', 'meta_key' => 'dob' ); $bday = new WP_Query($args); if ($bday->have_posts()) : echo '<aside id="birthdays" class="widget">'; echo '<h5>Today\'s birthdays</h5>'; echo '<ul>'; while ($bday->have_posts()) : $bday->the_post(); $dob = get_post_meta($post->ID, 'dob', true); $bdate = substr($dob, 0, strrpos($dob, '/')); $today = date('m/d'); if ( $today == $bdate ) { ?> <li class=""><a href="<? the_permalink(); ?>" title="See all galleries from the birthday babe"><? the_title(); ?></a></li> <? } endwhile; echo '</ul>'; echo '</aside>'; else : endif;
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Multi query array()’ is closed to new replies.