Skip to content

Instantly share code, notes, and snippets.

@mwangepatrick
Created December 23, 2022 07:19
Show Gist options
  • Save mwangepatrick/89879c4d86b944fa9184d00271483f4f to your computer and use it in GitHub Desktop.
Save mwangepatrick/89879c4d86b944fa9184d00271483f4f to your computer and use it in GitHub Desktop.
<?php
$current_date = date( 'md' ); // first load the current date into a variable, formatted as md
$employee_birthdays = new WP_Query(
array(
'posts_per_page' => -1,
'post_type' => 'member', // employee
'meta_query' => array(
array(
'key' => 'birthday', // assumes the date picker field is called birthday. Stored in Ymd format.
'value' => '\d\d\d\d'.$current_date,
'compare' => 'REGEXP',
),
),
)
);
while ( $employee_birthdays->have_posts() ) {
$employee_birthdays->the_post();
echo '<li>' . get_the_title() . ' : '.get_field('birthday', get_the_ID()).'</li>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment