Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook allows you to manipulate how a view is ordered.
Formidable Forms is the best WordPress Form Builder plugin. Get it for free!
Usage
add_filter('frm_view_order', 'change_view_order', 10, 2); function change_view_order($query, $args)
Parameters
- $query (array)
- $args (array)
Examples
Order by Month
This example will allow you to order dates in a view by their month, ignoring the year in the date field.
add_filter('frm_view_order', 'change_view_order', 10, 2);
function change_view_order($query, $args){
if ( $args['display']->ID == 2412 ) { //replace 2412 with you Field ID
$query['order'] = 'ORDER BY MONTH(it.created_at) ASC';
}
return $query;
}