Support

Account

Home Forums Front-end Issues Custom field: extract day of month

Helping

Custom field: extract day of month

  • Hi everybody,

    I have a custom post type named “persons” and a custom field named “dateofbirth”.
    At the end of the page-output of the person, I would like to list a few other persons, who have the same DAY the date.

    So, if the date of the person is 19640215, I would like to show all entries, where the custom field of these persons contains the day of month “15”. (The same output I need for month and year on other pages).

    I have no idea, how the array of the query has to look like. Can anybody help me?

    Thank you very much in advance! 🙂
    Andreas

  • I solved the problem myself using a variable and REGEX 😉

     'meta_query' => array(
                        array(
                          'key'      => 'birthday',
                          'compare'  => 'REGEXP',
                          'value'    => $year.'[0-9]{2}[0-9]{2}', 
                        ),    
                      )
    ));
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.