I have something strange happening in one of my views.
I am doing a count of posts with certain filters for the past 7 days, and then for the past 30 days, so 30 days should always be greater than or equal to the 7 days total, but in my view it is coming up as less than?
These are the two count views:
View: bm-new-jobs-7-days
Selects 'jobs' with the following filters:
Post author filter
Select posts with the author set by the parent view
Post date filter
Select posts whose
Published date is after or equal to: day:PAST_ONE(7)
Loop output:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
</wpv-loop>
<!-- wpv-loop-end -->
[wpv-found-count]
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]0[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
View: bm-new-jobs-30-days
Selects 'jobs' with the following filters:
Post author filter
Select posts with the author set by the parent View.
Post date filter
Select posts whose
Published date is after or equal to: day:PAST_ONE(30)
Loop output:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
</wpv-loop>
<!-- wpv-loop-end -->
[wpv-found-count]
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]0[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
And this is the output for the other view which calls these two views:
Selects users with any role, no filters
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-conditional if="('[types usermeta="location"][/types]' eq check_user_from_same_location())"]
<div class = "row"> <strong>[wpv-user field="display_name"]</strong></div><br>
<div class = "row">
<p>Last 7 days</p>
</div>
<div class = "row">
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Emails:</a> [wpv-view name="bm-comms-7-days" toc = "1"]</div>
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Phone:</a> [wpv-view name="bm-comms-7-days" toc = "2"]</div>
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Meetings:</a> [wpv-view name="bm-comms-7-days" toc = "3"]</div></div><br>
<div class = "row">
<div class = "col-xs-4 col-md-2">
New Jobs:
[wpv-view name="bm-new-jobs-7-days"]</div>
<div class = "col-xs-4 col-md-2">
CVs Sent:
[wpv-view name="bm-cvs-sent-7-days"]</div>
<div class = "col-xs-4 col-md-2">
Lost Jobs:
[wpv-view name="bm-lost-jobs-7-days"]</div>
<div class = "col-xs-4 col-md-2">
1st Interview:
</div>
<div class = "col-xs-4 col-md-2">
2nd Interview:
</div>
<div class = "col-xs-4 col-md-2">
Placements:
</div>
</div><br>
<div class = "row">
<p>Last 30 days</p>
</div>
<div class = "row">
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Emails:</a> [wpv-view name="bm-comms-30-days" toc = "1"]</div>
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Phone:</a> [wpv-view name="bm-comms-30-days" toc = "2"]</div>
<div class = "col-xs-4 col-md-2">
<a href = "<em><u>hidden link</u></em>">Meetings:</a> [wpv-view name="bm-comms-30-days" toc = "3"]</div></div><br>
<div class = "row">
<div class = "col-xs-4 col-md-2">
New Jobs:
[wpv-view name="bm-new-jobs-30-days"]</div>
<div class = "col-xs-4 col-md-2">
CVs Sent:
[wpv-view name="bm-cvs-sent-30-days"]</div>
<div class = "col-xs-4 col-md-2">
Lost Jobs:
[wpv-view name="bm-lost-jobs-30-days"]</div>
<div class = "col-xs-4 col-md-2">
1st Interview:
</div>
<div class = "col-xs-4 col-md-2">
2nd Interview:
</div>
<div class = "col-xs-4 col-md-2">
Placements:
</div>
</div><br>
[/wpv-conditional]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
This calls the following function to only display the users in the same location as the logged in user:
function check_user_from_same_location($type, $object) {
if ( $type == 'users' ) {
if ( empty( $object) ) {
$return = 0;
} else {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$user_location = get_user_meta($user_id, 'wpcf-location', true);
switch ($user_location) {
case 1:
$return = 'Durban';
break;
case 2:
$return = 'Joburg';
break;
case 3:
$return = 'Cape Town';
break;
case 4:
$return = 'Pietermaritzburg';
break;
case 5:
$return = 'Head Office';
break;
}
}
}
return $return;
}
As you can see from the attached screenshot the count for 7 days for new jobs is 5, but the count for 30 days is zero? I don't understand?