public
Last active

  • Download Gist
patch.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
--- link-template.php 2009-01-24 01:33:37.000000000 -0800
+++ link-template.php 2009-05-30 11:10:41.000000000 -0700
@@ -950,6 +950,9 @@
else
$post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
+ $rel = 'next';
+ if($previous) $rel = 'prev';
+
if ( !$post )
return;
@@ -961,7 +964,7 @@
$title = apply_filters('the_title', $title, $post);
$date = mysql2date(get_option('date_format'), $post->post_date);
- $string = '<a href="'.get_permalink($post).'">';
+ $string = '<a rel="'.$rel.'" href="'.get_permalink($post).'">';
$link = str_replace('%title', $title, $link);
$link = str_replace('%date', $date, $link);
$link = $string . $link . '</a>';
plugin.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php
/*
Plugin Name: rel=prev/next
Plugin URI: http://singpolyma.net/plugins/
Description: Adds rel/prev/next to next/previous posts links
Version: 0.1
Author: Stephen Paul Weber
Author URI: http://singpolyma.net
License: MIT license (http://www.opensource.org/licenses/mit-license.php)
*/
 
add_filter('next_posts_link_attributes', 'get_next_posts_link_attributes');
add_filter('previous_posts_link_attributes', 'get_previous_posts_link_attributes');
 
if (!function_exists('get_next_posts_link_attributes')){
function get_next_posts_link_attributes($attr){
$attr .= 'rel="prev"';
return $attr;
}
}
if (!function_exists('get_previous_posts_link_attributes')){
function get_previous_posts_link_attributes($attr){
$attr .= 'rel="next"';
return $attr;
}
}
 
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.