Changeset 11049 for trunk/wp-includes/link-template.php
- Timestamp:
- 04/22/2009 08:44:37 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r11013 r11049 1423 1423 1424 1424 /** 1425 * Return post pages link navigation for previous and next pages. 1426 * 1427 * @since 2.8 1428 * 1429 * @param string|array $args Optional args. 1430 * @return string The posts link navigation. 1431 */ 1432 function get_posts_nav_link( $args = array() ) { 1433 global $wp_query; 1434 1435 $return = ''; 1436 1437 if ( !is_singular() ) { 1438 $defaults = array( 1439 'sep' => ' — ', 1440 'prelabel' => __('« Previous Page'), 1441 'nxtlabel' => __('Next Page »'), 1442 ); 1443 $args = wp_parse_args( $args, $defaults ); 1444 1445 $max_num_pages = $wp_query->max_num_pages; 1446 $paged = get_query_var('paged'); 1447 1448 //only have sep if there's both prev and next results 1449 if ($paged < 2 || $paged >= $max_num_pages) { 1450 $args['sep'] = ''; 1451 } 1452 1453 if ( $max_num_pages > 1 ) { 1454 $return = get_previous_posts_link($args['prelabel']); 1455 $return .= preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $args['sep']); 1456 $return .= get_next_posts_link($args['nxtlabel']); 1457 } 1458 } 1459 return $return; 1460 1461 } 1462 1463 /** 1425 1464 * Display post pages link navigation for previous and next pages. 1426 1465 * … … 1431 1470 * @param string $nxtlabel Optional Label for next pages. 1432 1471 */ 1433 function posts_nav_link( $sep = ' — ', $prelabel = '« Previous Page', $nxtlabel = 'Next Page »' ) { 1434 global $wp_query; 1435 if ( !is_singular() ) { 1436 $max_num_pages = $wp_query->max_num_pages; 1437 $paged = get_query_var('paged'); 1438 1439 //only have sep if there's both prev and next results 1440 if ($paged < 2 || $paged >= $max_num_pages) { 1441 $sep = ''; 1442 } 1443 1444 if ( $max_num_pages > 1 ) { 1445 previous_posts_link($prelabel); 1446 echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep); 1447 next_posts_link($nxtlabel); 1448 } 1449 } 1472 function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) { 1473 $args = array_filter( compact('sep', 'prelabel', 'nxtlabel') ); 1474 echo get_posts_nav_link($args); 1450 1475 } 1451 1476
Note: See TracChangeset
for help on using the changeset viewer.