Support » Plugins and Hacks » [Resolved] Removing link rel='prev' and link rel='next' using all in one SEO

[Resolved] Removing link rel='prev' and link rel='next' using all in one SEO

  • Hi There
    I am using your great plugin.
    I have a site which for personal reasons I need to remove
    link rel=’prev’ and link rel=’next’
    from the head.

    ususally I use a function which easily removes it from the head:
    remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);

    Now, when I use All in one SEO, the function is not working anymore..
    does it have anything to do with the plugin settings?
    anyway I can remove link rel=’prev’ and link rel=’next’ and still using this plugin?



Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Contributor Peter Baylies



    There isn’t a filter for this in All in One SEO Pack yet; I’ll see about adding one. In the meantime, open up aioseop_class.php and search for ‘prev’ and you should see two lines that look like this:

    if ( !empty( $prev ) ) $meta_string .= "<link rel='prev' href='" . $prev . "' />\n";
    if ( !empty( $next ) ) $meta_string .= "<link rel='next' href='" . $next . "' />\n";

    You may comment them out or remove them.

    Hi Peter
    I tried it and it only removed it from the homepage.
    when I was browsing my inner pages it’s still there – next and previous
    BTW – If I do use your suggestion, isn’t it going to be overridden in the next time I update the plugin?


    Plugin Contributor Peter Baylies



    Is the rel prev / next on the inner pages inside the All in One SEO Pack comments, or outside? If outside, then it’s not coming from All in One SEO Pack and your other method might work to remove them. Yes it will be overridden the next time you update the plugin, but by then I should have a hook or two in place to fix this and will be able to give you better advice for the long term.

    You are right. it is outside the All in One SEO Pack comments.
    my function didn’t work so I added another function which works great.
    if anyone needs it:

    add_filter( 'index_rel_link', 'disable_stuff' );
    add_filter( 'parent_post_rel_link', 'disable_stuff' );
    add_filter( 'start_post_rel_link', 'disable_stuff' );
    add_filter( 'previous_post_rel_link', 'disable_stuff' );
    add_filter( 'next_post_rel_link', 'disable_stuff' );
    function disable_stuff( $data ) {
    	return false;

    written by Justin Tadlock

    I appreciate your help and your consideration of adding it to the next plugin update
    Thanks a lot!

    Hi hamergil,

    Thank you for your code. Works like a charm.



    hamergil thanks for your code. But if url have only numbers(for example 123456) also need add:

    add_filter('aioseop_prev_link', 'disable_stuff');
    add_filter('aioseop_next_link', 'disable_stuff');


    Thanks for the tip Anton.

    Has there been an update to this issue?

    I’m dealing with a site that has version 2.1.4 of AIO installed and the link rel=’next’ code is within the AIO area within the head section on the home page.

    Plugin Contributor Peter Baylies


    Hi prompos123,

    Do the code samples provided by hamergil or Anton work for you? I did add two filters for this, which are the ones Anton referenced.

    These lines are in my aioseop_class.php file, but the link rel=’next’ is still in my header.

    $prev = apply_filters( 'aioseop_prev_link', $prev );
    $next = apply_filters( 'aioseop_next_link', $next );
    Plugin Contributor Peter Baylies


    Yes, that is correct. The hooks are there, you just have to use them; i.e., see the code samples and instructions above in this thread.

    Peter, I’m not that experienced with WP code so you’ll have to help me out a bit more. 🙂

    Where would I add this code within aioseop_class.php and would it be overwritten when the plugin is updated?

    add_filter('aioseop_prev_link', 'disable_stuff');
    add_filter('aioseop_next_link', 'disable_stuff');
    Plugin Contributor Peter Baylies


    hi prompos123,

    You wouldn’t do that; add that code to the functions.php of your theme and make sure you have a corresponding function present as well. i.e. try this instead (and make sure you’re running at least version 3.7 of WordPress):

    add_filter('aioseop_prev_link', '__return_empty_string' );
    add_filter('aioseop_next_link', '__return_empty_string' );

    Excellent. That worked perfectly. Thanks Peter.

    what i must add to my function.php if i have wordpress 3.5? 🙂

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Resolved] Removing link rel='prev' and link rel='next' using all in one SEO’ is closed to new replies.