Ecommerce Shopify WordPress Discussion

WordPress paginate_links returns same 10 pages

I have the following code where the issue is that the paginate_links returns the same 10 results when clicking on next. The url changes and I can see it calculates the correct pagination so It knows which posts(events) are there. Is there something I need to parse into the paginate_links array so it knows it is the event posts it is dealing with? <?php $today = date('Ymd'); $wp_query = new WP_Query(array( 'post_type' => 'event', 'meta_key' => 'event_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'nopaging' => false, 'meta_query' => array( array( 'key' => 'event_date', 'compare' => '>=', 'value' => $today, 'type' => 'numeric' ) ) )); while($wp_query->have_posts()) { $wp_query->the_post(); ?> <div class="event-summary"> <a class="event-summary__date" href="<?php the_permalink(); ?>"> <span class="event-summary__day"><?php $eventDate = new DateTime(get_field('event_date')); echo $eventDate->format('d') ?></span> <span class="event-summary__month"><?php echo $eventDate->format('M') ?></span> <span class="event-summary__year"><?php echo $eventDate->format('Y') ?></span> </a> <div class="event-summary__content"> <h5 class="event-summary__title headline headline--tiny"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5> <p class="event-summary__excerpt"><?php if (has_excerpt()) { echo get_the_excerpt(); } else { echo wp_trim_words(get_the_content(), 18); } ?> <a href="<?php the_permalink(); ?>" class="">Læs mere</a></p> </div> </div> <?php } echo paginate_links(array( 'prev_text' => '<span>« Previous</span>', 'next_text' => '<span>Next »</span>' )); ?>
In order for the query to show the next page you'll need to include the current page index to the query with the paged key. This will change when you go to the next page, effectively showing the next x amount of posts. It's also a good idea to include the posts_per_page to indicate when the next page is available. $paged = get_query_var('paged') ? (int) get_query_var('paged') : 1; $wp_query = new WP_Query(array( 'post_type' => 'event', 'paged' => $paged, 'posts_per_page' => 5, 'meta_key' => 'event_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'nopaging' => false, 'meta_query' => array( array( 'key' => 'event_date', 'compare' => '>=', 'value' => $today, 'type' => 'numeric' ) ) ));

December 31, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.