I am new in wordpress. I have limit my post from my products category to 6, but in the reading settings of my wordpress it is by default post per page = 10. I want to do the next/previous postlink only from my products category where i have limiting it to 6 post per page:
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'products',
'posts_per_page' => '6',
);
$productsBlog = new WP_Query( $args );
?>
I want to put next/previous post link within only in products category without adjusting the reading settings in wordpress and adjust the postperpage by default that is equal to 10 post per page.
Here is my fullcode with my next/previous postlink:
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'products',
'posts_per_page' => '6',
);
$productsBlog = new WP_Query( $args );
$count = 0;
if( $productsBlog->have_posts() ) :
?>
<div class="container">
<ul class="image">
<div class="row row-centered">
<?php while ( $productsBlog->have_posts() ) : $productsBlog->the_post(); ?>
<div class="col-xs-4 col-box1" onMouseOver="show_title<?php echo $count ?>()" onMouseOut="hide_title<?php echo $count ?>()">
<li class="top-featured-image">
<span class="effect" id="hoverli<?php echo $count ?>"><?php the_title( sprintf('<a href="%s">', esc_url(get_permalink())),'</a>'); ?></span>
<?php the_post_thumbnail('productsize'); ?>
<?php the_title(); ?>
</div>
<?php if($count==2) :
echo '</div>';
echo '<div class="row row-centered">';
endif; ?>
</li>
<?php $count++; endwhile; ?>
</ul>
</div>
</div>
<div class="row controller-post">
<div class="col-md-6">
<?php next_posts_link('<< Older Posts'); ?>
</div>
<div class="col-md-6">
<?php previous_posts_link('Newer Posts >>'); ?>
</div>
</div>
<br><br>
<?php endif;
wp_reset_postdata();
?>