Hey guys. Facing really big issue here. I can't get pagination to work on category's page and it brings 404 error page. The struggle is huge. So far I added <?php wp_reset_query(); ?>
to archive.php.
And this to my functions.php:
function remove_page_from_query_string($query_string)
{
if ($query_string['name'] == 'page' && isset($query_string['page'])) {
unset($query_string['name']);
// 'page' in the query_string looks like '/2', so i'm spliting it out
list($delim, $page_index) = split('/', $query_string['page']);
$query_string['paged'] = $page_index;
}
return $query_string;
}
// I will kill you if you remove this. I died two days for this line
add_filter('request', 'remove_page_from_query_string');<code></code>
Now atleast I don't see the 404 page but now I see only the first page or atleast the first's page elements but the url changes also with the page navigation which has the following code:
function wp_bootstrap_pagination( $args = array() ) {
$defaults = array(
'range' => 4,
'custom_query' => FALSE,
'previous_string' => __( '<i class="glyphicon glyphicon-chevron-left"></i>', 'text-domain' ),
'next_string' => __( '<i class="glyphicon glyphicon-chevron-right"></i>', 'text-domain' ),
'before_output' => '<div class="post-nav"><ul class="pager">',
'after_output' => '</div>'
);
$args = wp_parse_args(
$args,
apply_filters( 'wp_bootstrap_pagination_defaults', $defaults )
);
$args['range'] = (int) $args['range'] - 1;
if ( !$args['custom_query'] )
$args['custom_query'] = @$GLOBALS['wp_query'];
$count = (int) $args['custom_query']->max_num_pages;
if ( get_query_var('paged') ) {
$page = get_query_var('paged');
}
elseif ( get_query_var('page') ) {
$page = get_query_var('page');
} else {
$page = 1;
}
//$page = intval( get_query_var( 'paged' ) );
$ceil = ceil( $args['range'] / 2 );
if ( $count <= 1 )
return FALSE;
if ( !$page )
$page = 1;
if ( $count > $args['range'] ) {
if ( $page <= $args['range'] ) {
$min = 1;
$max = $args['range'] + 1;
} elseif ( $page >= ($count - $ceil) ) {
$min = $count - $args['range'];
$max = $count;
} elseif ( $page >= $args['range'] && $page < ($count - $ceil) ) {
$min = $page - $ceil;
$max = $page + $ceil;
}
} else {
$min = 1;
$max = $count;
}
$echo = '';
$previous = intval($page) - 1;
$previous = esc_attr( get_pagenum_link($previous) );
$firstpage = esc_attr( get_pagenum_link(1) );
if ( $firstpage && (1 != $page) )
$echo .= '<li class="previous">' . __( 'Първа', 'text-domain' ) . '';
if ( $previous && (1 != $page) )
$echo .= '
- ' . $args['previous_string'] . '
';
if ( !empty($min) && !empty($max) ) {
for( $i = $min; $i <= $max; $i++ ) {
if ($page == $i) {
$echo .= '<li class="active"><span class="active">' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span>';
} else {
$echo .= sprintf( '
- %002d
', esc_attr( get_pagenum_link($i) ), $i );
}
}
}
$next = intval($page) + 1;
$next = esc_attr( get_pagenum_link($next) );
if ($next && ($count != $page) )
$echo .= '
- ' . $args['next_string'] . '
';
$lastpage = esc_attr( get_pagenum_link($count) );
if ( $lastpage ) {
$echo .= '<li class="next">' . __( 'Последна', 'text-domain' ) . '';
}
if ( isset($echo) )
echo $args['before_output'] . $echo . $args['after_output'];
}
?>`
Please help and advice :(
WordPress ...