I need to create a paginator in my blog page, until this its good, but when i click in a link of my pagination i got NOT FOUND page, i need to know if i need to able something in the panel to wordpress able the access to ?page=N
function:
function get_pagination($the_query) {
global $paged;
$total_pages = $the_query->max_num_pages;
$big = 999999999;
if ($total_pages > 1) {
ob_start();
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '/page/%#%',
'current' => $paged,
'total' => $total_pages,
'prev_text' => '',
'next_text' => ''
));
return ob_get_clean();
}
return null;
}
my blog code
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// echo $paged;
$produtos = new WP_Query(array(
'post_type' => 'blog',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'asc',
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'categorias',
'field' => 'slug',
'terms' => ACTIVE
)
)
));
while ( $produtos->have_posts() ) : $produtos->the_post();
//CONTENT
endwhile;
echo get_pagination($produtos);
Go to admin Dashboard then
Settings->Reading
then setBlog pages show at most
is equal to you queryposts_per_page
. So in your query if you setposts_per_page => 2
thenBlog pages show at most
will be2
This is what I found and resolved the issue I had!
use following paged query
Please check your .htaccess file. It should contain a rewrite rule to enable pagination with slashes.
Please see:
“Using pretty permalinks” – http://codex.wordpress.org/Using_Permalinks
Go to your wordpress Dashboard Settings then Reading and in the “Blog pages show at most” field, changed the value from ’10’ to ‘1’
cheers!