php - WordPress custom pagination rewrite does not work -
i selecting info custom table in wordpress. want utilize pagination results. i'm using next function pagination:
$wp_query->query_vars['page'] > 1 ? $current = $wp_query->query_vars['page'] : $current = 1; $pagination = array( 'base' => @add_query_arg('page','%#%'), 'format' => '', 'total' => ceil($total_posts / $items_per_page), 'current' => $current, ); echo paginate_links( $pagination ); however returns urls like:
http://example.com/author/xxx/?page=1 i want rewrite urls this:
http://example.com/author/xxx/page/1 for i'm using next code:
if ( $wp_rewrite->using_permalinks() ) $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'page' ); if ( !empty( $wp_query->query_vars['s'] ) ) $pagination['add_args'] = array( 's' => get_query_var( 's' ) ); the above code formats urls correctly, when go page 2, gives 404 error.
php wordpress pagination
No comments:
Post a Comment