I have a problem to make paging appear on a WordPress page using WP-Pagenavi.
The post_type
"pronamic_event" exists in the database and brings all the items of the query.
I was able to identify that the error is in the return of the variable $paged
that does not return anything, so it always takes the else from the ternary condition, which in this case is 1. How to find out where $paged
is?
Follow the code.
<?php
get_header(); ?>
<div class="agenda-10-wrap">
<div class="top">
<h3><?php if(function_exists('bcn_display')) bcn_display() ?></h3>
<h1><?php single_cat_title(); ?></h1>
</div>
<div class="main">
<div class="col-01">
<div class="content">
<ul>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => '12',
'paged' => $paged,
'post_type' => 'pronamic_event'
);
$loop = new WP_Query( $args );
//loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<li>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('post-thumbnails');
}
?>
<p><?php pronamic_the_start_date('d.m.y');?> - <?php pronamic_the_location();?></p>
<h4><?php the_title(); ?></h4>
<?php $excerpt = get_the_excerpt();?>
<p><?php echo string_limit_words($excerpt,25); ?>...</p>
<a href="<?php the_permalink() ?>">Leia mais</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<div class="bottom-pager">
<nav>
<?php if(function_exists('wp_pagenavi')){
wp_pagenavi( array( 'query' => $wp_query ) );
wp_reset_postdata();
} ?>
</nav>
</div>
</div>
<div class="col-02">
<?php get_sidebar( 'publicidade-ultimas' ); ?>
</div>
</div>