Custom loop next and previous post links not working

I’m using WP Events Manager and Advanced Custom Fields to develop a site, I have a custom post type called ‘event’ which I want to display via the below:

<article class="col-main col clearfix">
        <table>
            <tr>
                <th>Cours</th>
                <th>Niveau</th>
                <th>Dates</th>
                <th>Heures</th>
            </tr>
<?php

$args = array( 
    'post_type' => 'event',
    'posts_per_page' => 10,
    'paged' => get_query_var('paged'),
    'order' => 'ASC',
    'orderby' => 'meta_value',
    'meta_key' => '_event_start_date');
$loop = new WP_Query( $args );

if($loop->have_posts()):

while ( $loop->have_posts() ) : $loop->the_post();

$EM_Event = em_get_event($post->ID, 'post_id');

?>
            <tr>
                <td><?php echo $EM_Event->output('#_EVENTLINK'); ?></td>
                <td><?php the_field('niveau'); ?></td>
                <td><?php if($slug != 'stages-ete'): ?>Chaque: <?php the_field('jours'); echo '<br />'; endif; echo $EM_Event->output('#_EVENTDATES'); ?></td>
                <td><?php echo $EM_Event->output('#_EVENTTIMES'); ?></td>
            </tr>
<?php endwhile;?>
<?php else: ?>
        <tr><td colspan="3"><em>Pas de cours à venir.</em></td></tr>
<?php endif; ?>
        </table>
        <div class="navigation">
            <div class="next-posts"><?php next_posts_link('&laquo; Older Entries'); ?></div>
            <div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;'); ?></div>
        </div>
    </article>

But it’s not displaying the previous and next links. Any ideas?

Read More

Thanks

Related posts

Leave a Reply

1 comment

  1. Try adding the arguments this way instead

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'post_type' => 'event',
        'posts_per_page' => 10,
        'paged' => $paged,
        'order' => 'ASC',
        'orderby' => 'meta_value',
        'meta_key' => '_event_start_date');
    );