Title: Multi query array()
Last modified: August 20, 2016

---

# Multi query array()

 *  Resolved [Beee](https://wordpress.org/support/users/beee/)
 * (@beee)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/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)

 *  Thread Starter [Beee](https://wordpress.org/support/users/beee/)
 * (@beee)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/multi-query-array/#post-3214500)
 * Fixed it (I think)…
    For those who care to know…
 *     ```
       $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 '<ul>';
       		$counter = 0;
       	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');
       		$today = "03/14";
       		if ( $today == $bdate )
       		{
       			$counter++;
       			if ( $counter == 1 )
       			{
       ?>
       					<li class=""><h5>Today's birthdays</h5></li>
       					<li class=""><a href="<? the_permalink(); ?>" title="See all galleries from the birthday babe"><? the_title(); ?></a></li>
       <?
       			} // endif counter == 1
       			if ( $counter > 1 )
       			{
       ?>
       					<li class=""><a href="<? the_permalink(); ?>" title="See all galleries from the birthday babe"><? the_title(); ?></a></li>
       <?
       			} // endif counter > 1
       		} // endif (today == bdate)
       	endwhile;
       	echo '</ul>';
       	echo '</aside>';
       	else : endif;
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Multi query array()’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Beee](https://wordpress.org/support/users/beee/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/multi-query-array/#post-3214500)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
