Skip to content

Commit 373d66c

Browse files
committed
Added missing link attributes per issue #61
1 parent 4b4f99c commit 373d66c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

functions.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,70 @@ function tersus_rss_thumb($content) {
472472
}
473473

474474

475+
// Add missing attributes to next and previous post links
476+
477+
function add_next_post_attributes($attr) {
478+
$attr = str_replace("href=", 'title="View the next post" href=', $attr);
479+
return $attr;
480+
}
481+
function add_prev_post_attributes($attr) {
482+
$attr = str_replace("href=", 'title="View the previous post" href=', $attr);
483+
return $attr;
484+
}
485+
add_filter('next_post_link', 'add_next_post_attributes');
486+
add_filter('previous_post_link', 'add_prev_post_attributes');
487+
488+
489+
// Add missing attributes to next and previous image links
490+
491+
function add_next_image_attributes($attr) {
492+
$attr = str_replace("href=", 'title="View the next image" rel="next" href=', $attr);
493+
return $attr;
494+
}
495+
function add_prev_image_attributes($attr) {
496+
$attr = str_replace("href=", 'title="View the previous image" rel="prev" href=', $attr);
497+
return $attr;
498+
}
499+
add_filter('next_image_link', 'add_next_image_attributes');
500+
add_filter('previous_image_link', 'add_prev_image_attributes');
501+
502+
503+
// Add missing attributes to next and previous post page links
504+
505+
if ( !function_exists( 'add_next_posts_attributes' ) ) {
506+
function add_next_posts_attributes($attr) {
507+
$attr = 'rel="next" title="View the next page of posts"';
508+
return $attr;
509+
}
510+
}
511+
if ( !function_exists( 'add_prev_posts_attributes' ) ) {
512+
function add_prev_posts_attributes($attr) {
513+
$attr = 'rel="prev" title="View the previous page of posts"';
514+
return $attr;
515+
}
516+
}
517+
add_filter('next_posts_link_attributes', 'add_next_posts_attributes');
518+
add_filter('previous_posts_link_attributes', 'add_prev_posts_attributes');
519+
520+
521+
// Add missing attributes to next and previous comment page links
522+
523+
if ( !function_exists( 'add_next_comments_attributes' ) ) {
524+
function add_next_comments_attributes($attr) {
525+
$attr = 'rel="next" title="View the next page of comments"';
526+
return $attr;
527+
}
528+
}
529+
if ( !function_exists( 'add_prev_comments_attributes' ) ) {
530+
function add_prev_comments_attributes($attr) {
531+
$attr = 'rel="prev" title="View the previous page of comments"';
532+
return $attr;
533+
}
534+
}
535+
add_filter('next_comments_link_attributes', 'add_next_comments_attributes');
536+
add_filter('previous_comments_link_attributes', 'add_prev_comments_attributes');
537+
538+
475539
// Tests whether post paging links should be shown
476540

477541
function show_post_link_nav() {

0 commit comments

Comments
 (0)