I create ad custom post type register_post_type( 'videos', $args);
and custom taxonomy for that register_taxonomy( 'video_category_categorie', 'videos', $args );
Maximum number of post displayed is 2 per page. Via word press backend
in archive-videos. php i write the for displaying the post from a specific taxonomy ( taxonomy item id is 3 ) $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'videos','paged' => $paged,'tax_query' => array(
array(
'taxonomy' => 'video_category_categorie',
'field' => 'term_id',
'terms' => 3)
));
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo get_the_title().'<br>';
endwhile;
twentyfourteen_paging_nav();
Now i get the result correctly only pst from taxonomy id 3 is displayed.
But the pagination is not correct. it showing 1 2 3 4 . actually there is 5 post that is in taxonomy id 3 . so the correct pagination is 1 2 3 .
And also when clicking 4 page the page didnât show any post name .
Please help
If you look at the source for
twentyfourteen_paging_nav()
, you’ll see it acts upon the$GLOBALS['wp_query']
, not on your custom loop query.If you want to keep using
twentyfourteen_paging_nav()
, you need to use the standard loop, and modifyquery_posts
to alter the globalwp_query
object instead of your$loop
, which is a separate instance ofWP_Query
.In your case, that would mean changing the line:
to:
and removing
$loop->
from the rest of your code.If you can’t do that for any reason, you’ll need to switch to another WordPress pagination function