Conditional statement to show pagination

Conditional statement to show pagination on WordPress archive or blog page

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
}
?>
Previous Code

HTML img tag to HTML SVG tag [WordPress]

Image to SVG for WordPress. Generate svg code from ...

Next Code

Jquery Custom Tab

TweetShareSharePin0 Shares ...

0 Comment

    Leave a Reply

    Your email address will not be published.

    15 + 4 =

    Remove Website field from WordPress comment & Change cookies remember text

    Remove Website field from WordPress comment & Chan ...

    WordPress Next and Previous Post

    WordPress Next and Previous Post navigation for cu ...

    WordPress Ajax Search without plugin [ Easy ]

    WordPress Ajax Search without plugin. Fully custom ...

    Protected: WP user Login Notification

    This code is Protected. Contact Admin for password

    Add Custom element item in wp nav menu

    Add Element on last item of wp nav menu ...

    ACF

    JavaScript

    jQuery

    Others

    PHP

    WooCommerce

    WordPress

    skype

    Need Coding Help?

    Connect Skype
    top