Skip to main content
Rollback to Revision 2
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

EDIT

This is the solution I came up with.

<?php 
    global $paged;
    $curpage = $paged ? $paged : 1;
    $upcoming = new WP_Query();
    $upcoming->query( array(
        'post_type'=> 'tribe_events',
        'eventDisplay' => 'upcoming',
        'posts_per_page' => 2,
        'paged' => $paged)
    );

    if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
            
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

    <?php endwhile;


    echo '<div id="navigation">';
        if ($curpage != 1) {
           echo '<a class="previous" href="'.get_pagenum_link(($curpage-1 > 0 ? $curpage-1 : 1)).'">&lsaquo;</a>';
        }
        if ($curpage != $upcoming->max_num_pages) {
           echo '<a class="next" href="'.get_pagenum_link(($curpage+1 <= $upcoming->max_num_pages ? $curpage+1 : $upcoming->max_num_pages)).'">&rsaquo;</a>';
        }            
    echo '</div>';

    endif;

    wp_reset_query(); 
?>

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

EDIT

This is the solution I came up with.

<?php 
    global $paged;
    $curpage = $paged ? $paged : 1;
    $upcoming = new WP_Query();
    $upcoming->query( array(
        'post_type'=> 'tribe_events',
        'eventDisplay' => 'upcoming',
        'posts_per_page' => 2,
        'paged' => $paged)
    );

    if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
            
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

    <?php endwhile;


    echo '<div id="navigation">';
        if ($curpage != 1) {
           echo '<a class="previous" href="'.get_pagenum_link(($curpage-1 > 0 ? $curpage-1 : 1)).'">&lsaquo;</a>';
        }
        if ($curpage != $upcoming->max_num_pages) {
           echo '<a class="next" href="'.get_pagenum_link(($curpage+1 <= $upcoming->max_num_pages ? $curpage+1 : $upcoming->max_num_pages)).'">&rsaquo;</a>';
        }            
    echo '</div>';

    endif;

    wp_reset_query(); 
?>

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>
added 1126 characters in body
Source Link
hyperdrive
  • 257
  • 2
  • 9
  • 14

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

EDIT

This is the solution I came up with.

<?php 
    global $paged;
    $curpage = $paged ? $paged : 1;
    $upcoming = new WP_Query();
    $upcoming->query( array(
        'post_type'=> 'tribe_events',
        'eventDisplay' => 'upcoming',
        'posts_per_page' => 2,
        'paged' => $paged)
    );

    if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
            
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

    <?php endwhile;


    echo '<div id="navigation">';
        if ($curpage != 1) {
           echo '<a class="previous" href="'.get_pagenum_link(($curpage-1 > 0 ? $curpage-1 : 1)).'">&lsaquo;</a>';
        }
        if ($curpage != $upcoming->max_num_pages) {
           echo '<a class="next" href="'.get_pagenum_link(($curpage+1 <= $upcoming->max_num_pages ? $curpage+1 : $upcoming->max_num_pages)).'">&rsaquo;</a>';
        }            
    echo '</div>';

    endif;

    wp_reset_query(); 
?>

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

EDIT

This is the solution I came up with.

<?php 
    global $paged;
    $curpage = $paged ? $paged : 1;
    $upcoming = new WP_Query();
    $upcoming->query( array(
        'post_type'=> 'tribe_events',
        'eventDisplay' => 'upcoming',
        'posts_per_page' => 2,
        'paged' => $paged)
    );

    if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
            
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

    <?php endwhile;


    echo '<div id="navigation">';
        if ($curpage != 1) {
           echo '<a class="previous" href="'.get_pagenum_link(($curpage-1 > 0 ? $curpage-1 : 1)).'">&lsaquo;</a>';
        }
        if ($curpage != $upcoming->max_num_pages) {
           echo '<a class="next" href="'.get_pagenum_link(($curpage+1 <= $upcoming->max_num_pages ? $curpage+1 : $upcoming->max_num_pages)).'">&rsaquo;</a>';
        }            
    echo '</div>';

    endif;

    wp_reset_query(); 
?>
deleted 50 characters in body; edited title
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

The Event Plugin Query Pagination for event query

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar.?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

I would appreciate any help on this. Thank You.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

The Event Plugin Query

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar.

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

I would appreciate any help on this. Thank You.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>

Pagination for event query

I'm working on a WP_Query using the Modern Tribe Events Calendar

My problem is with pagination.

Is this the incorrect way to paginate the WP_Query or could there be another method for paginating the Events Calendar?

I found a tutorial that uses the WPNavi plugin but I would like use core wordpress functions.

<?php 
$upcoming = new WP_Query();
$upcoming->query( array(
    'post_type'=> 'tribe_events',
    'eventDisplay' => 'upcoming',
    'posts_per_page' => 1)
);

if ($upcoming->have_posts()) : while ($upcoming->have_posts()) : $upcoming->the_post(); ?>
        
        <?php tribe_get_template_part( 'list/single', 'event' ) ?>

<?php endwhile;

else : 
    echo 'no upcoming events'; 
endif;

wp_reset_query(); 
?>

<div class="navigation"><p><?php posts_nav_link(); ?></p></div>
Source Link
hyperdrive
  • 257
  • 2
  • 9
  • 14
Loading