• Resolved my29

    (@my29)


    Hello,

    I am using your plugin to load 20 events per scroll from Events Calendar Plugin and I customized the display to filter out the passed events. Unfortunately, when I customized it seems there is a maximum of 2 pages only. Meaning only 40 events were loaded. Is there a way to set the maximum pages to infinite?

    I tried every possible code like max_num_page set to 0 but not working. Please help!

    This is the code I wrote to filter out passed events:

    function upcoming_event($args) {

    $date_today = date(‘Y-m-d’);
    $date_cutoff = date(‘Y-m-d’, strtotime($date_today . ‘ -1 days’));

    $now = new DateTime();
    $end = $now->format( ‘Y-m-d H:i:s’ );
    $begin = $now->modify( ‘-10 days’ )->format( ‘Y-m-d H:i:s’ );

    if ($_GET[‘page’] == ‘0’) {
    $offset = ”;
    } else {
    $offset = $_GET[‘page’];
    }

    $args = [
    ‘post_status’ => ‘publish’,
    ‘post_type’ => array(TribeEvents::POSTTYPE),
    ‘posts_per_page’ => 20,
    ‘meta_key’ => ‘_EventStartDate’,
    ‘orderby’ => ‘_EventStartDate’,
    ‘order’ => ‘ASC’,
    ‘eventDisplay’ => ‘custom’,
    ‘offset’ => $offset,
    ‘meta_query’ => [
    ‘key’ => ‘_EventEndDate’,
    ‘value’ => $date_today,
    ‘compare’ => ‘>=’,
    ‘type’ => ‘DATE’
    ]
    ];

    return $args;

    } add_filter(‘alm_query_args_upcoming_event’, ‘upcoming_event’);

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @my29,
    I’m not 100% sure what the issue is, but I notice you are modifying the offset param where the docs say to never modify this.
    https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_query_args

    Let me know if that helps at all.

    Thread Starter my29

    (@my29)

    Hi @dcooney,

    My problem is only 2 pages consisting of 20 per page were loaded. I don’t know if it has problem with the maximum page. I am not sure. I didn’t set maximum value but still it limits to 2 pages and the second page just repeating the lists in the first page.

    I tried removing the offset but still did not work.

    Plugin Author Darren Cooney

    (@dcooney)

    As I said, don’t modify the offset parameter.

    Remove this.

    if ($_GET[‘page’] == ‘0’) {
    $offset = ”;
    } else {
    $offset = $_GET[‘page’];
    }
    Thread Starter my29

    (@my29)

    Yes, I removed that too but still did not work.

    Plugin Author Darren Cooney

    (@dcooney)

    Your syntax is very incorrect and you are also redeclaring $args instead of simply modifying it as shown in the example.

    Try this.

    function upcoming_event($args) {
    
       $date_today = date('Y-m-d');
    
       $args['post_status'] = 'publish';
       $args['post_type'] = array(TribeEvents::POSTTYPE);
       $args['meta_key'] = '_EventStartDate';
       $args['orderby'] = '_EventStartDate';
       $args['order'] = 'ASC';
       $args['eventDisplay'] = 'custom';
       $args['meta_query'] = array(
          array(
             'key'     => '_EventEndDate',
             'value'   => $date_today,
             'compare' => '>=',
             'type'   => 'DATE'
          )
      );
       
      return $args;
    
    } 
    add_filter('alm_query_args_upcoming_event', 'upcoming_event');

    If this doesnt work, try changing some of the values to see where things are going wrong.

    Also, set posts_per_page on the shortcode not in the filter.

    Thread Starter my29

    (@my29)

    @dcooney,

    Sorry, I am really confused about it. That’s exactly what I need! Thanks a lot! Your code really help! It’s working now. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Infinite Maximum pages’ is closed to new replies.