2310 | | if ( $GLOBALS['wp_query']->max_num_pages > 1 ) { |
2311 | | $args = wp_parse_args( $args, array( |
2312 | | 'mid_size' => 1, |
2313 | | 'prev_text' => __( 'Previous' ), |
2314 | | 'next_text' => __( 'Next' ), |
2315 | | 'screen_reader_text' => __( 'Posts navigation' ), |
2316 | | ) ); |
2317 | | // Make sure we get plain links, so we can work with it. |
2318 | | $args['type'] = 'plain'; |
| 2310 | if ( $wp_query->max_num_pages < 2 ) { |
| 2311 | return; |
| 2312 | } |
2323 | | if ( $links ) { |
2324 | | $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] ); |
2325 | | } |
| 2319 | if ( isset( $url_parts[1] ) ) { |
| 2320 | wp_parse_str( $url_parts[1], $query_args ); |
| 2321 | } |
| 2322 | |
| 2323 | $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); |
| 2324 | $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; |
| 2325 | |
| 2326 | $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; |
| 2327 | $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; |
| 2328 | |
| 2329 | $args = wp_parse_args( $args, array( |
| 2330 | 'base' => $pagenum_link, |
| 2331 | 'format' => $format, |
| 2332 | 'add_args' => array_map( 'urlencode', $query_args ), |
| 2333 | 'total' => $wp_query->max_num_pages, |
| 2334 | 'current' => $paged, |
| 2335 | 'mid_size' => 1, |
| 2336 | 'prev_text' => __( 'Previous' ), |
| 2337 | 'next_text' => __( 'Next' ), |
| 2338 | 'screen_reader_text' => __( 'Posts navigation' ), |
| 2339 | ) ); |
| 2340 | |
| 2341 | $navigation = ''; |
| 2342 | |
| 2343 | // Set up paginated links. |
| 2344 | $links = paginate_links( $args ); |
| 2345 | |
| 2346 | if ( $links ) { |
| 2347 | $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] ); |