Pagination doesn't show on pages (2 posts)

  1. waseembari1985
    Posted 1 year ago #

    Hi everyone,

    I am using Bootstrap and WordPress. Below is the code for my one of the page, I don't know why it doesn't show the pagination. I think there is some problem with my Query but unable to find it out. Please have a look on below code and suggest me.

    <section <?php post_class("col-md-9") ?> id="post-<?php the_ID(); ?> layout-thumbs">
    <h1><span><?php wp_title(''); ?></span></h1>
    	$args = array('orderby'=> 'date','order' => 'DESC','tag__not_in' => 40, 42, 'cat'=> '-22', 'posts_per_page' => 1,
      'paged' => $paged);
    	$allposts = new WP_Query($args);
    	<?php while ( $allposts->have_posts() ) : $allposts->the_post(); ?>
        <li <?php post_class('col-md-4 thumbnail') ?> id="post-<?php the_ID(); ?>">
                    if ( has_post_thumbnail() ) {
                    the_post_thumbnail(); // the current post has a thumbnail
                } else { ?>
                    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/no-car-image.png" alt="No Image" />
                <?php }?>
            <div class="caption">
            	<div style="height:70px;">
                <h3><a>"><span><?php the_field('year', $post_id); ?> <?php $category = get_the_category(); $parent_cat = $category[0]->category_parent; echo get_cat_name($parent_cat); ?> <?php $category = get_the_category(); echo $category[0]->cat_name; ?></span></a></h3>
                <a>" class="link">Details   →</a>
    	<?php endwhile; ?>
    <?php page_navi(); ?>
    <?php get_footer(); ?>
  2. Mohsin Patel
    Posted 1 year ago #

    From code seems like your are using <?php page_navi(); ?> for displaying paging.

    Please make sure that this function is available in functions.php OR related plugin for supporting that function is active.

    Another Alternative Way :

    Simply replace <?php page_navi(); ?>

    with below code

    global $wp_query;
    $big = 999999999; // need an unlikely integer
    echo paginate_links( array(
    'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
    'format' => '?paged=%#%',
    'current' => max(2, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages,
    'show_all' => false,
    'prev_next' => True,
    'prev_text' => __('« Previous'),
    'next_text' => __('Next »')
    ) );?>

    For more details you can refer the below tutorials which explain much deeper level of replacement of the code

    [ link moderated ]

    Let me know if any difficulties further to make it work.

Topic Closed

This topic has been closed to new replies.

About this Topic