WordPress.org

Support

Support » Plugins and Hacks » Select posts (Students) with meta_key 'birthday' value between two dates

Select posts (Students) with meta_key 'birthday' value between two dates

  • Hi All,

    I’m currently working on a WordPress website for a lower school. They want to have a widget that displays all the students who have their birthday that week. I have made a meta_key with value 2008-06-29.

    I’m trying the following.

    $args = array(
    	'post_type' => 'student',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		array(
    			'key'     => '_birthday',
    			'value'   => array( $start, $end ),
    			'compare' => 'BETWEEN',
    		),
    	),
    	'order' => 'ASC',
    	'orderby' => 'meta_value',
    	'meta_key' => '_birthday'
    );

    Start = %-06-24
    End = %-06-30

    But that isn’t working. Does someone know how to get these posts?

    Many thanks in advance.

  • The topic ‘Select posts (Students) with meta_key 'birthday' value between two dates’ is closed to new replies.
Skip to toolbar