WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Danny de Haan
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic