Next and Previous Pagination button not displaying in WordPress

Question

I have more than 15 posts and I am displaying only 6 per page load and remaining will display after the click on the pagination but the issue is I am not getting my pagination.

I am using below code

function recentPost_on_home(){
ob_start();
?>
<div class="cp-seeWrapper"><div class="row"><div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-xs-12"><div class="row">
   <?php $args = array('posts_per_page' => 6);
            $tyler_query = new WP_Query( $args );
            if ($tyler_query->have_posts()) {
                while ( $tyler_query->have_posts() ) {
                    $tyler_query->the_post();
            $categories = get_the_category(); $names = ''; if ( $categories && is_array( $categories )) { foreach ( $categories as $cat ) { $names .= $cat->name . ' '; } }?>
                <div class="col-xl-6 col-lg-6 col-md-6 col-sm-12 col-xs-12">
                    <div class="cp-shadow cp-seeSinglePostWrapper">
                    <?php echo get_the_post_thumbnail();?>
                        <div class="bg-white single-post-box">
                            <div class="d-flex cp-CategoryList">
                                <div class="seeDate"><?php echo get_the_date('F j, Y');?></div>
                                <?php echo $names;?>
                            </div>
                            <div class="cp-heading"><h3><a href="<?php echo esc_url( get_the_permalink() );?>" title="<?php echo esc_attr( the_title_attribute('echo=0'));?>" class="seePost_title"><?php echo wp_trim_words(get_the_title(), 10, '...');?></a></h3></div>
                                <p><?php echo wp_trim_words(get_the_excerpt(), 20, '...');?></p>
    </div>
                            </div>
                        </div>
            <?php  }?>
    <div class="nav-previous alignleft">hello<?php next_posts_link(); ?></div>
   <div class="nav-next alignright"><?php echo previous_posts_link( 'Newer posts' ); ?></div>
    <?php       }?>
    </div>
</div>
    <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
        <!--some logic here-->
      </div>
  </div>
</div>

    <?php return ob_get_clean(); 
}
add_shortcode( 'home_recent_post', 'recentPost_on_home' );

The second issue is, I am getting all the categories of the single product, I have to display only 2 categories.

For example, product is IOS and categories are iPhone and iMac,iPod. So I have to display iPhone and iMac only.

0
, , , , Naren Verma 2 years 2019-11-02T10:12:45-05:00 0 Answers 83 views 0

Leave an answer

Browse
Browse