Only issue is that on initial page load it shows posts from all months and not only the ones from the current month. From what I read in Waqas final reply it seems the updated code in his post should support current month on intial view?
Solution:
There are some PHP errors in the custom PHP codes, I suggest debug the codes line by line manually.
Relevant Documentation:
This support ticket is created 5 years, 11 months ago. 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.
Does exactly what I need and I have it working here hidden link
Only issue is that on initial page load it shows posts from all months and not only the ones from the current month. From what I read in Waqas final reply it seems the updated code in his post should support current month on intial view?
There are some issues in the thread you mentioned above, please try these:
1) Edit the post view of your website, for example the post view's ID is 123,
in section "Query Filter", change the filter to:
Select items with field:
release-date is a string equal to 03-2019
We will use below filter to change the month value
if($view_settings['view_id'] != 123){ //if it is specific view
return $query;
}
$mm = date("m-Y", time()); // current month by default
if(isset($_REQUEST["mm"])){ // if it is pagination URL
$mm = $_REQUEST["mm"];
}
Yes, according to our support policy, we don't provide custom codes support, you can also check it with our Toolset Contractors: https://toolset.com/contractors/
Could you please help regarding the code you provided in matter of errors in my error.log file?
I get a lot of these
PHP Warning: Missing argument 3 for my_filter_query(), called in /home/public_html/wp-includes/class-wp-hook.php on line 288 and defined in /home/public_html/wp-content/themes/wp-clear2017/functions.php on line 100
This is what I have in the functions file
function my_filter_query($query, $view_settings, $view_id) {
if($view_settings['view_id'] != 74955){ //if it is specific view
return $query;
}
$mm = date("m-Y", time()); // current month by default
if(isset($_REQUEST["mm"])){ // if it is pagination URL
$mm = $_REQUEST["mm"];
}
if(!empty($mm)) {
if (is_array($query['meta_query'])) {
foreach($query['meta_query'] as $i => $meta_query) {
//print_r($meta_query);
if (isset($meta_query['key']) && $meta_query['key'] == 'wpcf-program-tidspunkt') {
$start = strtotime("1-{$mm} 00:00:00");
$numdays = date("t", $start);
$end = strtotime("$numdays-{$mm} 23:59:59");
$meta_query['value'] = "$start,$end";
$meta_query['compare'] = 'BETWEEN';
$query['meta_query'][$i] = $meta_query;
}
}
}
}
return $query;
}
add_filter('wpv_filter_query', 'my_filter_query', 12, 2);
add_shortcode("next-month", "get_next_month");
function get_next_month($atts) {
$mm = $_REQUEST["mm"];
if(empty($mm)) {
$mm = date("m-Y", time());
}
$nextmonth = date("m-Y", strtotime("1-{$mm} +1 month"));
return $nextmonth;
}
add_shortcode("prev-month", "get_prev_month");
function get_prev_month($atts) {
$mm = $_REQUEST["mm"];
if(empty($mm)) {
$mm = date("m-Y", time());
}
$prevmonth = date("m-Y", strtotime("1-{$mm} -1 month"));
return $prevmonth;
}