Skip Navigation

[Resuelto] View that shows posts published today

This support ticket is created hace 10 años. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 2 respuestas, has 2 mensajes.

Last updated by Stanislav hace 10 años.

Assisted by: Ghennadi.

Autor
Mensajes
#162919

I'm trying to make a View that displays posts that were published today.

I checked the Date Filters docuentation:
https://toolset.com/documentation/user-guides/date-filters/

There is a solution, but only for date custom fields created through Types. I want to do the same thing but on the post published date.

How to do that?

#163364

Dear Stanislav,

WordPress just introduced a new set of query arguments for filter by date. We will add date filter in next releases.
For now you can use this method:

Add this code to your theme/functions.php

add_filter( 'wpv_filter_query', 'wpv_show_today_posts' );
function wpv_show_today_posts( $query_args ) {
    global $WP_Views;
    if ( !is_admin() && isset($WP_Views->current_view) && $WP_Views->current_view == YOURVIEWID ) {
        $query_args['date_query'] = array(
										array(
											'year'  => date('Y'),
											'month' => date('m'),
											'day'   => date('d'),
										),
									);
    }
    return $query_args;
}

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.
Regards,
Gen.

#163374

Thanks Ghennadi,

As long as this makes it in the next version I am happy. 🙂

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.