![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Susan,
So the issue is that the date is being stored incorrectly as a full string.
Is there a way for you to modify your code so that it is stored correctly as a timestamp?
I'm assuming this is what sets the date value to the database correct?
'value' => $form->get_campaign_value( 'startdate' ),
Please let me know as we need to convert this to a timestamp.
Thanks,
Shane
Hi Shane,
After a bit of research and working with the plugin author there is no easy solution to get the dates to show up as dates versus text. His solution is that a WP_Query can be used to display the posts to order by meta value, where the meta value is interpreted as a date.
$query = new WP_Query( array(
'post_type' => 'campaign',
'meta_key' => '_campaign_startdate',
'orderby' => 'meta_value_date',
'order' => 'ASC',
) );
My issue comes in as to how to integrate this into the Toolset view so I can properly display the data.
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Susan,
You can actually use a hook to do this.
add_filter( 'wpv_filter_query', 'date_filter_func', 10, 3 );
function date_filter_func( $query, $settings, $view_id ) {
if ( $view_id == 1416 ) {
$query = new WP_Query( array(
'post_type' => 'campaign',
'meta_key' => '_campaign_startdate',
'orderby' => 'meta_value_date',
'order' => 'ASC',
) );
}
return $query;
}
Change the id of the view and it should work.
Thanks,
Shane
Hi Shane,
This still does not work. If I put the id of the view (5971), the page where the view's content template is suppose to show does not even render. If I put the id of the content template (5972) the page renders but the content is still not sorted correctly.
Any other ideas or can you go in and see what might be wrong ? This seems like such a simple thing that is just causing such an issue.
Thanks.
![](https://secure.gravatar.com/avatar/f3c36bb8920f6b75cd720f131c6a9065?s=80&d=mm&r=g)
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Susan,
So the issue we are facing here is that your date field is stored as a plain text string.
Now from what i've been reading it won't be possible to sort the date as it is.
It would need to be stored as a timestamp in order for us to sort it correctly.
Thanks,
Shane