Hi rEaS,
There isn’t a good way to do this with the args in shortcodes. What you need is a date_query, and the shortcode args can’t handle array notation. http://codex.ww.wp.xz.cn/Class_Reference/WP_Query#Date_Parameters .
There is a bug in the current release, or else you could handle this with a custom hook. I’ll try to push out a simple bug-fix-only release this evening. Then I’ll respond here with how to use the hook to achieve what you need.
Sorry for the issues, more to come this evening.
Thread Starter
rEaS
(@reas)
Oh my god, thank you so much dude! I’ll be eagerly waiting for it!
Hi rEaS,
I’ve fixed the bug that was preventing the custom hooks from working correctly in version 1.5.25.
I think this code will accomplish your date_query. You’ll need to put it in your theme’s function.php or a custom plugin.
// custom hook into query-wrangler before the query is executed
add_filter( 'qw_pre_query', 'my_qw_pre_query_filter', 10, 2 );
// my custom hook callback
function my_qw_pre_query_filter( $args, $options ){
// only alter the targeted query
if ( 'homepage-most-popular' == $options['meta']['slug'] ){
$args['date_query'] = array(
'before' => '5 days ago',
'after' => '60 days ago',
);
}
return $args;
}
In the future, I hope to have date_query as part of the UI. In the meantime, for more options on the date query, check the codex: http://codex.ww.wp.xz.cn/Class_Reference/WP_Query#Date_Parameters .
Let me know how this turns out!
Thanks,
Jonathan
Thread Starter
rEaS
(@reas)
ok let me try it, where do i get the latest code and whats the best way of manually updating a plugin in wordpress.. just copy over the files?
Visit your Updates page ( /wp-admin/update-core.php ). It will detect there is an update and let you perform the update with a click.
If it doesn’t list Query Wrangler there, click on “Check Again” button at the top. If it still doesn’t show up, give it 20 minutes and try again. Sometimes I have issue with very-recent updates.
Thread Starter
rEaS
(@reas)
holy cow! this worked great! but great..! thank you very much, anyone needing to filter a query by date, just use that filter and play with the dates/days.
jonathan thank you so much for your help! im sending some cash your way for your help tomorrow when i get in the office!
thanks again!