splorp / tersus

An achingly simple WordPress theme without all the usual cruft.
GNU General Public License v3.0
99 stars 6 forks source link

Add ‘title’ and ‘rel’ attributes to page navigation links #61

Closed splorp closed 2 years ago

splorp commented 10 years ago

The following page navigation functions do not add title or rel attributes to links, like post navigation functions do. This is dumb.

next_posts_link() previous_posts_link() next_image_link() previous_image_link() next_comments_link() previous_comments_link()

We can probably use this snippet as the basis for filtering to the affected functions.

I’ve also stumbled across the following filter hooks, which might be useful.

next_posts_link_attributes previous_posts_link_attributes next_comments_link_attributes previous_comments_link_attributes

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="myrel" title="mytitle"';
        return $attr;
    }
}
if (!function_exists('get_previous_posts_link_attributes')){
    function get_previous_posts_link_attributes($attr){
        $attr = 'rel="myrel" title="mytitle"';
        return $attr;
    }
}