Hi,
I’m trying to build a looper to retreive a custom post type (in this case Modern Events Calendar events mec-events
) and have run into a problem getting my code to work.
I have created a WP_Query a follows (you’ll see what I’m trying to do from the code):
add_filter( 'cs_looper_custom_molly_events_data', 'molly_gigs_events_loop', 10, 1);
function molly_gigs_events_loop($result) {
$today = date('Ymd');
$args = array(
'post_type' => 'mec-events',
'post_status' => 'publish',
'posts_per_page' => '9',
'meta_key' => 'mec_start_date',
'meta_query' => array(
'key' => 'mec_start_date',
'value' => $today,
'compare' => '>='
),
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$result = new WP_Query ($args);
return $result;
}
I’ve then added a looper provider with a type of custom, and the hook pointed at molly_events_data
:
However, I have now noticed that maybe the Custom looper type doesn’t accept a WP_Query
like I have created? Your documentation here seems to suggest that my function should return some kind of JSON format?
Could someone please clarify what I am allowed to return from my ‘custom’ function, and the best way to acheive this? Otherwise, I’ll have to go back to coding this kind of thing manually…
Many thanks…