0

in the template page loop get posts from tag which name is raspee, post per page are 5. pagination show in the page but not working..

What is problem in my code??

Template-page

<?php /* Template Name: Raspee */ ?>

<?php get_header(); ?>

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$original_query = $wp_query;
$wp_query = null;
$args=array('posts_per_page'=>5 , 'tag' => raspee );
$wp_query = new WP_Query( $args );

if ( have_posts() ) :
    while (have_posts()) : the_post();
    get_template_part('content');

endwhile;

next_posts_link();
previous_posts_link(); 

endif;
$wp_query = null;
$wp_query = $original_query;    
wp_reset_postdata();    
?>  

<?php get_footer(); ?>
5

You have not add "paged" in WP_Query args array ,that's why your pagination not working. try this code , it will work definitely

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$original_query = $wp_query;
$wp_query = null;
$args=array('posts_per_page'=>5, 'tag' => 'raspee', 'paged'=>$paged);
$wp_query = new WP_Query( $args );
  • 1
    '$args=array('posts_per_page'=>5 , 'tag' => 'raspee' ,paged'=>$paged);' editing this line thats way now its work fine... – FRQ6692 Jul 26 '16 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.