php - worpress pagination doesn't work for next or preview page
Get the solution ↓↓↓I want to add pagination in my wordpress page, but when the page display
And when i'm try to click next arrow or page 2, after the page reload data display doesn't match. But what's wrong here?
this is my code to display data and pagination:
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$wp_query= new WP_Query(array(
'post_type' => 'jobs',
'post_status' => 'publish',
'orderby' => 'publish_date',
'order' => 'DESC',
'posts_per_page' => 3,
// 'paged' => $paged
));
while ( $wp_query->have_posts() ) :
$wp_query->the_post();
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'large', true);
?>
<div class="card content-box">
<!-- pass it -->
</div>
<?php
endwhile;
//this is code to pagination
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => '<i class="fa fa-long-arrow-left"></i>',
'next_text' => '<i class="fa fa-long-arrow-right"></i>',
));
if( is_array( $pages ) ) :
foreach ($pages as $key => $value) { ?>
<li class="page-item">
<?php
if ( $value ) {
$value = str_replace( 'page-numbers', 'page-link', $value);
}
echo $value;
?>
</li>
<?php
}
wp_reset_postdata;
endif;
?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: uncaught mysqli_sql_exception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.