WordPress.org

Ready to get started?Download WordPress

Forums

All in One SEO Pack
[resolved] Removing link rel='prev' and link rel='next' using all in one SEO (20 posts)

  1. hamergil
    Member
    Posted 8 months ago #

    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?

    Thanks

    http://wordpress.org/plugins/all-in-one-seo-pack/

  2. Peter Baylies
    Member
    Plugin Author

    Posted 8 months ago #

    hamergil,

    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.

  3. hamergil
    Member
    Posted 8 months ago #

    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?

    Thanks

  4. Peter Baylies
    Member
    Plugin Author

    Posted 8 months ago #

    hamergil,

    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.

  5. hamergil
    Member
    Posted 8 months ago #

    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!

  6. Ambhen
    Member
    Posted 5 months ago #

    Hi hamergil,

    Thank you for your code. Works like a charm.

    Cheers,
    Ambhen

  7. Anton Silin
    Member
    Posted 5 months ago #

    Hello,

    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!

  8. hamergil
    Member
    Posted 5 months ago #

    Thanks for the tip Anton.

  9. prompos123
    Member
    Posted 4 months ago #

    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.

  10. Peter Baylies
    Member
    Plugin Author

    Posted 4 months ago #

    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.

  11. prompos123
    Member
    Posted 4 months ago #

    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 );
  12. Peter Baylies
    Member
    Plugin Author

    Posted 4 months ago #

    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.

  13. prompos123
    Member
    Posted 4 months ago #

    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');
  14. Peter Baylies
    Member
    Plugin Author

    Posted 4 months ago #

    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' );
  15. prompos123
    Member
    Posted 4 months ago #

    Excellent. That worked perfectly. Thanks Peter.

  16. Valonix
    Member
    Posted 4 months ago #

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

  17. Valonix
    Member
    Posted 4 months ago #

    and one more question, why i can`t this do at plugin settings? maybe you can add this in new versions? ;)

  18. Peter Baylies
    Member
    Plugin Author

    Posted 4 months ago #

    Valonix,

    Same thing. This thread is for WordPress 3.7 though and it's resolved; in general I'd suggest that you update WordPress to the latest version whenever possible.

  19. Valonix
    Member
    Posted 4 months ago #

    i can`t update. maybe there is another way?

  20. jason404
    Member
    Posted 3 months ago #

    I have commercial sites running on WordPress with custom-made themes.

    These rel='prev' and link rel='next' are showing up in the source, but pointing to non-existent pages.

    Is this causing a problem with SEO and is there something I can do about it?

    I am using the latest version of WordPress and the links are definitely within the additions made by this plugin.

Reply

You must log in to post.

About this Plugin

About this Topic