Hi,
You can see example here:
= With default query =
<?php
if(have_posts()):
while(have_posts()): the_post();
// Template loop here
endwhile;
echo easy_wp_pagenavigation();
else:
// No result
endif; wp_reset_query();
?>
= With custom query =
<?php
// You need protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'paged' => $paged,
);
$my_query = new WP_Query( $args );
if($my_query->have_posts()):
while($my_query->have_posts()): $my_query->the_post();
// Template loop here
endwhile;
echo easy_wp_pagenavigation( $my_query );
else:
// No result
endif; wp_reset_postdata();
?>
It’s easy to use 🙂
It is easy for you, not for me 🙂
I am not a programmer, i do not where I put this code.
You can’t add page navigation if you don’t add this code to your themes.
Because, wordpress not provide hook for add this to querys in theme, also in your themes, I don’t know query you use in templates.
So it’s imperative 🙂
Can we filter by category with Easy WP Page Navigation?
I need a way to page posts from just 1 category, not all posts… 🙁
Can we filter by several categories too?
Something like:
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'cat' => 21,
'paged' => $paged,
);
$my_query = new WP_Query( $args );
will work?
EDIT: it does! 😀 \o/
You should add https://codex.ww.wp.xz.cn/Class_Reference/WP_Query to the faq, or install section…
@luuuciano it’ll work 😉
I’m glad for it work with you 😉