There was some mistake in the code indeed, fixed now and I think it's more clear now:
[php]
add_filter('wpv_filter_query', 'posts_within_current_month', 10, 2);
function posts_within_current_month($query, $settings) {
if($settings['view_id'] = 123)
{
$query['meta_query'] = array(
array(
'key' => 'start_date',
'value' => array( strtotime('+1 month', date('Y-m-01')), strtotime('+1 month', date('Y-m-01'))),
'type' => 'date',
'compare' => 'BETWEEN',
),
),
}
return $query;
}
[php]
Hi Adriano
Thanks, but I just want to check, if I want the posts from the 1st to the 31st, should the second
strtotime('+1 month', date('Y-m-01'))
not actually be ('Y-m-31')??
Or am I misunderstanding what these are?
Oh man, my mistake again 🙁
add_filter('wpv_filter_query', 'posts_within_current_month', 10, 2);
function posts_within_current_month($query, $settings) {
if($settings['view_id'] = 123)
{
$query['meta_query'] = array(
array(
'key' => 'start_date',
'value' => array( strtotime('+1 month', date('Y-m-01')), strtotime('+1 month', date('Y-m-t'))),
'type' => 'date',
'compare' => 'BETWEEN',
)
);
}
return $query;
}
You should use t, because t represents the number of days in the month.
Please let me know if you are satisfied with my reply and any other questions you may have.
Regards,
Adriano Ferreira
Hi Adriano
I've tried to add this function, but when I do I get totals of 0 for every month??
I replaced the view id and the key (should this be in the format wpcf-start-date? I also tried start-date, but this didn't work either.)
I don't need to call the function from the loop output hey? It should just filter it from the view id huh?
Can you send me private message link so you can go in and check?
I can't access the site, is it online?
Hi Adriano
I can get to it on my side. Do you not get to the attached login screen?
No, I can't access. Is there any kind of protection there, maybe by IP?
Hi Adriano
I have disabled a couple of plugins that might be blocking you.
If you still cant get in please send me a screenshot or describe what it says when you try and go there.
Nothing, it's loading forever. No message displayed.
Hi Adriano
I asked my host and they say there might be something on their side blocking you.
Which country are you trying to access from?
Thanks
Gavin
Hi Adriano
IP blocking should be cleared now?
Great! What about FTP? I need that to send some changes.