Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Does someone perhaps know a plugin or snippet (besides Yoast's WordPress SEO) to accomplish this perhaps? Pagination with rel=“next” and rel=“prev”

The only thing I've come across seems to be an 3-month old Trac ticket.

share|improve this question
    
you can do this by using query and append it –  ntechi Dec 18 '11 at 17:40
    
@ntechi, thank you for your quick reply. My guess is however this answers about 99,9% of all questions listed here. I have to admit I was hoping for something a bit more detailed. –  Cor van Noorloos Dec 18 '11 at 17:49
    
your aim is to add a rel in next and previous link? –  ntechi Dec 18 '11 at 17:52
    
The one Google advises, yes. Not the ones that are currently used by WordPress default. –  Cor van Noorloos Dec 18 '11 at 17:54
    
@CorvanNoorloos The one Google advices is in the head section, not directly at the link element... –  kaiser Dec 18 '11 at 19:44

3 Answers 3

up vote 8 down vote accepted

Try putting this snippet in your functions.php

<?php
function rel_next_prev(){
    global $paged;

    if ( get_previous_posts_link() ) { ?>
        <link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>" /><?php
    }

    if ( get_next_posts_link() ) { ?>
        <link rel="next" href="<?php echo get_pagenum_link( $paged +1 ); ?>" /><?php
    }

}
add_action( 'wp_head', 'rel_next_prev' );
?>

And if you don't want the next and prev rel links to show up on the singular pages just wrap the output markup in a !is_singular() if condition

share|improve this answer
    
Thanks @Joshua, this works even better than the gist mentioned above! –  Cor van Noorloos Dec 20 '11 at 17:05
    
I would recommend using is_archive() instead of ! is_singular() –  Josh Mountain May 8 at 21:43

Ok then this will be a good solution:

$('YOUR_PAGINATION_A_ID').attr('rel', 'next');
$('YOUR_PAGINATION_A_ID').attr('rel', 'prev');

Try this, it might help you.

share|improve this answer
    
If I understand correct you're suggesting to let JavaScript handle this? Since Google or any other search engine doesn't understand JavaScript, I doubt this would be the ideal solution. –  Cor van Noorloos Dec 18 '11 at 18:17
    
yaa that would be, better would be you edit that PHP code itself or wait for another answer –  ntechi Dec 18 '11 at 18:18
    
It always be a good practice to do it server-side.. –  amit Jul 17 '12 at 0:30

This pretty much does exactly that, as a plugin - http://wordpress.org/extend/plugins/pagination-rel-links/

share|improve this answer
    
An answer should be more than just a link to an external site. Please add a solution. –  toscho Jul 6 '12 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.