I’m using the same custom wpquery format in my NEWS page. And my pagination uses WP PAGE NAVI
plugin. It does work on my NEWS PAGE
but doesnt work on my EVENTS PAGE
.
Plugins used:
1. WP PAGE NAVI
2. EVENTS MANAGER
Problem: When i click page 2 or next page. The page becomes 404
:
Here’s my code:
<?php
global $wp_query;
$old_query=$wp_query;
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
?>
<?php $wp_query = new WP_Query(array( 'post_type' => 'event', 'posts_per_page' => 3, 'paged' => $paged )); ?>
<?php while($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php $EM_Event = em_get_event($post->ID, 'post_id'); ?>
<div class="main-news-cont">
<div class="event-posts">
<div class="upcoming-date-cont2 fl">
<div class="upcoming-d2"><?php echo get_the_date('d'); ?></div>
<div class="upcoming-m-y2"><?php echo get_the_date('M Y'); ?></div>
</div>
<div class="news-title events-title"><a href="<?php the_permalink(); ?> ">
<?php the_title( '<h2>', '</h2>' ); ?>
</a></div>
<div class="events-time-loc">
<div class="events-time"> <span>Time</span>: 10:AM to 12:00PM</div>
<div class="events-loc"> <span>Location:</span> <?php echo do_shortcode('[locations_list]'); ?> </div>
</div>
</div>
<div class="clearfix"></div>
</div>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php wp_reset_postdata(); wp_reset_query(); ?>
<?php $wp_query=$old_query;?>
Also im not sure if i have to post this as a separate question. I cant seem to pull out the start and end time of my event in my loop: As of now it has static start time and end time in there.
Thanks! I really need you help guys!! Please!