Ok I know there are a lot posts on this already but I'm not able to find what is wrong with my code. Because pagination is still not working. The weird thing is the same code and template works fine on another site I'm using them on.
<?php
$type = get_sub_field('type');
$amount = get_sub_field('amount');
$previousLabel = $labels['previous_label'];
$nextLabel = $labels['next_label'];
?>
<div class="block-review block-review-<?php echo($type)?>">
<div class="content-wrapper">
<?php
if($type == 'list') {
// get list of posts
$pageQuery = (is_home())? 'page' : 'paged';
$paged = (get_query_var($pageQuery)) ? get_query_var($pageQuery) : 1;
$reviews = new WP_Query(
array(
'post_type' => 'review',
'posts_per_page' => $amount,
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
'meta_key' => 'meta_data_hide_review',
'meta_value' => '0'
)
);
// loop though reviews
if ($reviews->have_posts()):
while($reviews->have_posts()): $reviews->the_post();
require('element/review-item.php');
endwhile;
?>
<div style="display:none"><?php var_dump(get_query_var('page') . get_query_var('paged'))?></div>
<div class="review-pagination-wrapper">
<div class="review-pagination">
<?php
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $reviews->max_num_pages,
'current' => max( 1, get_query_var( $pageQuery ) ),
'format' => '?' . $pageQuery . '=%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => sprintf( '<i></i> %1$s', __( $previousLabel , 'text-domain' ) ),
'next_text' => sprintf( '%1$s <i></i>', __( $nextLabel , 'text-domain' ) ),
'add_args' => false,
'add_fragment' => '',
) );
?>
</div>
</div>
<?php
else:
// no posts
endif;
wp_reset_postdata();
}
?>
</div>
</div>
So the first page works fine, and pagination show up but i can't navigate to the next pages. Any help would be very very very appreciated.
Ok I know there are a lot posts on this already but I'm not able to find what is wrong with my code. Because pagination is still not working. The weird thing is the same code and template works fine on another site I'm using them on.
<?php
$type = get_sub_field('type');
$amount = get_sub_field('amount');
$previousLabel = $labels['previous_label'];
$nextLabel = $labels['next_label'];
?>
<div class="block-review block-review-<?php echo($type)?>">
<div class="content-wrapper">
<?php
if($type == 'list') {
// get list of posts
$pageQuery = (is_home())? 'page' : 'paged';
$paged = (get_query_var($pageQuery)) ? get_query_var($pageQuery) : 1;
$reviews = new WP_Query(
array(
'post_type' => 'review',
'posts_per_page' => $amount,
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
'meta_key' => 'meta_data_hide_review',
'meta_value' => '0'
)
);
// loop though reviews
if ($reviews->have_posts()):
while($reviews->have_posts()): $reviews->the_post();
require('element/review-item.php');
endwhile;
?>
<div style="display:none"><?php var_dump(get_query_var('page') . get_query_var('paged'))?></div>
<div class="review-pagination-wrapper">
<div class="review-pagination">
<?php
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $reviews->max_num_pages,
'current' => max( 1, get_query_var( $pageQuery ) ),
'format' => '?' . $pageQuery . '=%#%',
'show_all' => false,
'type' => 'plain',
'end_size' => 2,
'mid_size' => 1,
'prev_next' => true,
'prev_text' => sprintf( '<i></i> %1$s', __( $previousLabel , 'text-domain' ) ),
'next_text' => sprintf( '%1$s <i></i>', __( $nextLabel , 'text-domain' ) ),
'add_args' => false,
'add_fragment' => '',
) );
?>
</div>
</div>
<?php
else:
// no posts
endif;
wp_reset_postdata();
}
?>
</div>
</div>
So the first page works fine, and pagination show up but i can't navigate to the next pages. Any help would be very very very appreciated.
Share Improve this question edited Dec 10, 2019 at 8:53 kero 6,3401 gold badge25 silver badges34 bronze badges asked Dec 10, 2019 at 4:27 user179536user179536 111 bronze badge1 Answer
Reset to default 0Ok sorry for posting this question. Someone installed a SEO plugin that redirected every consecutive page the page back to the fist page.