how to fix paging in wp-PageNavi plugin with custom post type
the project site “shah.vn” I see the main problem is that old bug in wp-PageNavi plugin is paging error when I want to adjust the number of postings in the query, this default plugin is out of of Posts to configure the admin of the website.
I have a query such as the following for a custom post type:
$args = array('post_type' => 'home-decor', 'posts_per_page' => 30);
query_posts($args);
then returns the result as the number of products on the page will be displayed incorrectly, I remember that article I show you how to troubleshoot using the wordpress content analytics, today I show you a way much simpler, query segment you declare as follows:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$termid = get_queried_object()->term_id;
$que = array(
array(
'taxonomy' => 'decor',
'terms' => $termid,
'field' => 'id',
),
);
$args = array('post_type' => 'home-decor', 'posts_per_page' => 30, 'paged'=> $paged, 'tax_query' => $que);
query_posts($args);
in the above code has two significant parts you need:
1 section for information on the current page you are standing very simple, this is a statement in worpress.
2 queries take to get current taxonomy, without this line it will show all products in Custom Post Type “home-decor”. This is the basic command to do many other things you want to do: take all promotional products, all products Hot …
if you do not know about Custom Post Type and Taxonomy is nothing you can learn in this