Skip Navigation

[Résolu] Views 1.8 Sort by Post Date how to set two BETWEEN full dates YYYY/MM/DD to YYYY

This support ticket is created Il y a 8 années et 5 mois. 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 3 réponses, has 1 voix.

Last updated by nathanW-4 Il y a 8 années et 5 mois.

Auteur
Publications
#296975

Hi,

I've installed the new version of views which allows you to sort by post date. Which is great.

But I can't see a way to filter between two date ranges easily, I can filter between two YEARS but not Year, Month, Date.

One specific one that I need to do via url parameters is Financial year, which is June 31, to Jul 1 the following year. How can this be achieved with views?

URGENTLY need to figure this out.

Thanks

#296977

Also, if this could be updated via the existing ajax setup that would be ideal [rather than url param]

#296986

Hmmm, you've managed to make a date filter without the most basic necessity of a feature!

Simply needs to be able to filter between two dates, but it doesn't seem that views can do this even with the new version, what a let down!

Simply need the same as custom fields have - filter between to fields yyyy mm dd and yyyy mm dd.

#296993

Solved this with a custom query and url parameters. Shame views couldn't do it should have been easy.

For anyone else here's my code - it accepts 2 url parameters wpv-from-date and wpv-to-date, with the following date formats: MM/DD/YYYY

They can be added to a views page url like so:

?wpv-from-date=12/21/2012&wpv-to-date=9/6/2013

if($_GET["wpv-from-date"] && $_GET["wpv-to-date"]){
    
add_filter('wpv_filter_query', 'date_range', 99, 3 );

function date_range($query_args) {
    
    
    $fromdate = $_GET["wpv-from-date"];
    $todate = $_GET["wpv-to-date"];
    
    $query_args['date_query'][] = array(
          'after'         => $fromdate,
          'before'        => $todate
        );
    
  
    return $query_args;
   //var_dump($query_args);
        
}
    
    
}