Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is experiencing a 404 error when clicking to pagination page 2 on their blog, despite the pagination being set up correctly in the PHP code.
Solution:
We suggested checking if the issue persists when WPML is disabled, which would mean that it is not indicating a potential conflict with WPML. If the issue is related to WPML, we recommended providing WPML debugging information to further diagnose the problem. More information on how to provide this can be found here: https://wpml.org/faq/provide-debug-information-faster-support/

If this solution does not resolve the issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 0 voices.

Last updated by Andreas W. 3 weeks, 1 day ago.

Assisted by: Andreas W..

Author Posts
May 24, 2025 at 5:10 pm #17068930

stanislavD-7

Background of the issue:
I am trying to implement pagination for recent blog posts on my site hidden link using the following PHP code: <?php

$title = get_sub_field('title');
$sub_title = get_sub_field('sub_title');
$content = get_sub_field('content');
$section_link = get_sub_field('section_link');
$visability = get_sub_field('visability');

?>

<section class="container-wrap recent-blog-posts recent-blog-posts-pagination<?php if ($visability == 'hidden') { echo ' hidden'; }?>">

<div class="container-custom">
<div class="recent-blog-posts-wrap">
<?php if (!empty($title)): ?><h3 class="title"><?php echo $title; ?></h3><?php endif; ?>
<?php if (!empty($sub_title)): ?><h2 class="sub-title"><?php echo $sub_title; ?></h2><?php endif; ?>
<?php if (!empty($content)): ?><div class="content"><?php echo $content; ?></div><?php endif; ?>
<div class="recent-posts">
<?php
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$posts_per_page = 3;
$args = array(
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged,
);

$recent_posts = new WP_Query( $args );

if ( $recent_posts->have_posts() ) :
while ( $recent_posts->have_posts() ) :
$recent_posts->the_post();
?>
<div class="post-item">
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-image">
" title="">
<?php
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$title = get_the_title( get_the_ID() );
$img_url = get_the_post_thumbnail_url( get_the_ID() ) ?: 'https://cdn.wpml.org/wp-content/uploads/2025/05/Vector.png';
?>
<img src="<?php echo esc_url( $img_url ); ?>" alt="<?php echo esc_attr( $title ); ?>" title="<?php echo esc_attr( $title ); ?>">
</div>
<?php endif; ?>
<div class="post-content">
<div class="post-category">
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) : ?>
term_id ) ); ?>">
name ); ?>

<?php endif; ?>
</div>
<h3 class="post-title">
">


</h3>
<div class="post-excerpt">
<?php the_excerpt(); ?>
</div>
" class="read-more" title="">



</div>
</div>
<?php
endwhile;
?>
</div>
<?php
$total_pages = $recent_posts->max_num_pages;
if ( $total_pages > 1 ) :
?>
<div class="pagination-wrap initial">
<nav class="navigation pagination" role="navigation">
<div class="nav-links">
<?php
echo paginate_links(
array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'format' => '?paged=%#%',
'mid_size' => 1,
'prev_text' => __( '' ),
'next_text' => __( '' ),
'current' => $paged,
'total' => $total_pages,
)
);
?>
</div>
</nav>
</div>
<?php endif; ?>
<?php else : ?>
<p>No posts found.</p>
<?php endif; ?>

<?php wp_reset_postdata(); ?>
</div>
</div>
</div>

</section>

Symptoms:
When I click to pagination page 2, I am redirected to hidden link but the content is for 404.

Questions:
Why does the pagination redirect to a 404 page?
How can I fix the pagination issue on my site?

May 24, 2025 at 7:23 pm #17069057

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

It looks like this happens in site default languages.

What makes you think that this is a WPML issue? Does the issue disappear if you disable WPML?

If so, it would also be very helpful if you could provide us with WPML debugging information.
More information here:
https://wpml.org/faq/provide-debug-information-faster-support/

Best regards
Andreas