Next Day pagination Wordpress Toolset Views Plugin

About the client

Hjorring, Denmark

Posted on Feb 26, 2019 / Est. budget $ 250 / Project canceled

Skills required

I have an existing working montly pagination running here http://digital-tv.dk/2019/02/16/test-month-pagination/

Now I want to have a function also for next day / previous day pagination.

I am using Toolset Views plugin on Wordpress so the provided solution should be provided for this.

If you need to have knowledge of the Toolset Views plugin I do not know. But I can provide login for test site so you can test there.

 

Here below is the existing code for the current running next month / previous month in the Wordpress theme functions file. I would imaging this is a good starting point for a new function for next / previous day.

function my_filter_query($query, $view_settings, $view_id) {

 

if($view_settings['view_id'] != 38){ //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-start') {

                    $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;

}


Project bids (4)

Bids are visible only by project owner and Premium members.