Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php (revision 5443)
+++ wp-includes/default-filters.php (working copy)
@@ -160,6 +160,7 @@
add_action('wp_head', 'locale_stylesheet');
add_action('publish_future_post', 'wp_publish_post', 10, 1);
add_action('wp_head', 'noindex', 1);
+add_action( 'wp_head', 'link_rel_prev_next' );
add_action('wp_head', 'wp_print_scripts');
if(!defined('DOING_CRON'))
add_action('init', 'wp_cron');
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php (revision 5443)
+++ wp-includes/link-template.php (working copy)
@@ -352,8 +352,10 @@
// Navigation links
-function get_previous_post($in_same_cat = false, $excluded_categories = '') {
- global $post, $wpdb;
+function get_previous_post($in_same_cat = false, $excluded_categories = '', $id = 0) {
+ global $wpdb;
+
+ $post = &get_post( $id );
if( !is_single() || is_attachment() )
return null;
@@ -389,8 +391,10 @@
return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join $where $sort");
}
-function get_next_post($in_same_cat = false, $excluded_categories = '') {
- global $post, $wpdb;
+function get_next_post($in_same_cat = false, $excluded_categories = '', $id = 0) {
+ global $wpdb;
+
+ $post = &get_post( $id );
if( !is_single() || is_attachment() )
return null;
@@ -438,7 +442,7 @@
return;
$title = apply_filters('the_title', $post->post_title, $post);
- $string = '';
+ $string = '';
$link = str_replace('%title', $title, $link);
$link = $pre . $string . $link . '';
@@ -454,7 +458,7 @@
return;
$title = apply_filters('the_title', $post->post_title, $post);
- $string = '';
+ $string = '';
$link = str_replace('%title', $title, $link);
$link = $string . $link . '';
$format = str_replace('%link', $link, $format);
@@ -607,4 +611,62 @@
}
}
-?>
+function link_rel_prev_next( $id = 0 ) {
+ if ( !is_single() ) {
+ return;
+ }
+
+ $prev_url = '';
+ $next_url = '';
+
+ $post = get_post( $id );
+ setup_postdata( $post );
+
+ global $multipage, $numpages, $pagenow, $page, $wp_rewrite;
+
+ if ( $multipage ) {
+ global $numpages, $pagenow, $page;
+
+ if ( $page == 1 ) {
+ if ( $prev_post = get_previous_post( false, '', $post->ID ) ) {
+ $prev_url = get_permalink( $prev_post->ID );
+ }
+ } else {
+ if ( !$wp_rewrite->using_permalinks() || $post->post_status == 'draft' ) {
+ $prev_url = add_query_arg( 'page', $page - 1, get_permalink() );
+ } else {
+ $prev_url = trailingslashit( get_permalink() ) . user_trailingslashit( $page - 1, 'single_paged' );
+ }
+ }
+
+ if ( $page == $numpages ) {
+ if ( $next_post = get_next_post( false, '', $post->ID ) ) {
+ $next_url = get_permalink( $next_post->ID );
+ }
+ } else {
+ if ( !$wp_rewrite->using_permalinks() || $post->post_status == 'draft' ) {
+ $next_url = add_query_arg( 'page', $page + 1, get_permalink( $post->ID ) );
+ } else {
+ $next_url = trailingslashit( get_permalink() ) . user_trailingslashit( $page + 1, 'single_paged' );
+ }
+ }
+ } else {
+ if ( $prev_post = get_previous_post( false, '', $post->ID ) ) {
+ $prev_url = get_permalink( $prev_post->ID );
+ }
+
+ if ( $next_post = get_next_post( false, '', $post->ID ) ) {
+ $next_url = get_permalink( $next_post->ID );
+ }
+ }
+
+ if ( !empty( $prev_url ) ) {
+ printf( '' . "\n", $prev_url );
+ }
+
+ if ( !empty( $next_url ) ) {
+ printf( '' . "\n", $next_url );
+ }
+}
+
+?>
\ No newline at end of file