Error 404 blog/page/2/

Hello i have problem.

I can't view /blog/page/2/ i klick "_posts_link" and error 404 shows me

Blog Page -> home.php

                ?php 
                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $args = array('posts_per_page' = 5, 'paged' = $currentPage);
                query_posts($args);
                if( have_posts() ): $i = 0;

                    while( have_posts() ): the_post(); ?

                                ?php $i++; endwhile; ?
                                ul class="uk-pagination uk-background-primary uk-light"
                                    li?php next_posts_link('span class="uk-margin-small-right" uk-pagination-previous/span Stare Posty'); ?/li
                                    li class="uk-margin-auto-left"?php previous_posts_link('Nowe posty span class="uk-margin-small-left" uk-pagination-next'); ?/li
                                /ul

                                ?php endif;
                                    wp_reset_query();
                                ?      

Topic plugin-wp-pagenavi plugin-development posts Wordpress

Category Web


I guess you don't need to target a taxonomy. You can use the code below:

function query_change_function( $query ) {
     $query->set( 'posts_per_page', 5 );
}
add_action('pre_get_posts', 'query_change_function');

You should wrap the $query->set( 'posts_per_page', 5 ); around with if ( ! is_admin() && is_home() ) {//the $query->set code} to avoid it changing to 5-posts everywhere.


Use this for pagination

<?php
$paged = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1;
$content_args=array(
         'post_type' => 'post',
         'orderby' => 'meta_value_num',
         'paged' => $paged,
         'posts_per_page' => '5',
     );
    $wp_query = new WP_Query($content_args);
    while ($wp_query->have_posts()): $wp_query->the_post();?>

    //content here

   <?php endwhile;?>

Pagination

<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) 
),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages
) );?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.