December 30, 2024
1 min read

In wordpress you can use get_adjacent_post,which gives you the next post data it takes three parameters: $in_same_cat, $excluded_categories, and $previous.

if(get_adjacent_post(true, '', false)){
/* do what you want  */
}

Or if you are using wp loop you can check it by

global $wp_query;
if($wp_query->current_post + 1 < $wp_query->post_count){
/* do what you want  */
}

Full pagination code

Pagination
<?php 
global $wp_query;
if($wp_query->current_post + 1 < $wp_query->post_count){
?>
<section class="blog-pagination">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="blog_pagination">

                    <?php the_posts_pagination( array(
        'mid_size' => 2,
        'screen_reader_text' => _('Page','mukto'),
        'prev_text' => __( '<span class="fa fa-angle-left"></span>', 'mukto' ),
        'next_text' => __( '<span class="fa fa-angle-right"></span>', 'mukto' ),
        ) ); ?>
                </div>
            </div>
        </div>
    </div>
</section>
<?php
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

Change WordPress URL in Database with phpMyAdmin and SQL query

Replace WordPress old URL to new URL with SQL Query

Create a new WordPress administrator via functions.php & FTP

Sometimes, you might need to create an administrator account in WordPress without being able to access the admin dashboard. This could be because you have lost access to your site’s admin panel or when troubleshooting a client’s website. In this tutorial, we will show you how to programmatically add a WordPress administrator account using the […]

Allow Only Business Email Addresses in the Email Field of Elementor Forms

Find out how to restrict email fields in Elementor forms to business emails only. Improve form data quality by blocking free email domains like Gmail and Yahoo.

Implementing WooCommerce Shop Page Quantity Input and Plus (+) Minus (-) Button with simple Code

Enhance the user experience on your WooCommerce website by adding quantity plus minus buttons and a quantity option on the shop page.

Web Development Project in mind?

if you looking for a web developer for paid contribution to your project I am available for work.

Mukto
Mukto

Click the button below to chat with me.