Hey there, I hope you’re having a great day
I know what I’m about to ask is custom coding, but I’ve exhausted my options and wondered whether something may be broken with the custom looper provider… So here I am!
I’ve got a custom post type called “Social Events” which has some custom fields. I want to order the posts by the event start date meta setup by ACF as well as only show future events, hence the custom provider hook requirement.
I’ve got a div set as looper provider set to custom with a hook of get_recent_social
. It’s also set as the consumer with some elements inside to output post title etc.
In the backend I’ve got the below filter:
function ltm_get_recent_social($result){
$date_now = date('Y-m-d H:i:s');
$args = array(
'post_type' => 'social',
'post_status' => 'publish',
'meta_key' => 'start',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'start',
'compare' => '>=',
'value' => $date_now,
'type' => 'DATETIME'
)
),
);
$query = new WP_Query( $args );
return $query->posts;
}
add_filter( 'cs_looper_get_recent_social', 'ltm_get_recent_social', 10, 1);
The issue is that the looper says there aren’t any posts coming through. Now, if I var_dump($query->posts)
it spits out an array of 3 WP_Post objects, which is accurate.
So my conclusion is that either I’m not returning things in the correct format OR something is wrong with the custom looper system. Can you please help?