CustomPress data types?

Can anyone tell me the data types of the variables saved in CustomPress?

I created a date picker custom field and need to sort on that field in my get_posts() function. I'm not getting the results expected so I'm guessing it's not really a DATE field. Can anyone verify the data types for me?


  • thoward

    Managed to answer my own question again :slight_smile:

    So, in case you need, here is a quick rundown of how to use the datepicker as a custom field and then sort on that field in your template files:

    1. First is to set the datepicker format to yy-mm-dd. This will create a date that looks like 2013-03-25 as an example. This ISO format allows us to compare and sort later. Other formats may work, but this one I know does.

    2. You will need a custom get_posts function similar to:

    $todaysdate = date("Y-m-d");
    $args = array(
    'orderby'         => 'meta_value',
    	'meta_key' => '_ct_datepicker_514cdbb02453c',
    	'order'           => 'DESC',
    	'post_type'     => 	'events',
    	'meta_value'	=>	$todaysdate,
    	'meta_compare'	=>	'>=',
    	'post_status'     => 'publish');
    $myposts = get_posts( $args );

    Change 'meta_key' => '_ct_datepicker_514cdbb02453c' to your own meta_key value for your datepicker.

    Now you can loop normally and output the posts as needed. Hope this helps others.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.