Tuesday, October 5, 2010

Removing WordPress LINK: NEXT and PREV

In WordPress, in the HTML HEAD, there are two <link> lines that are present. One is rel="next" and the other is rel="prev". Now, if you have some pages that you don't want just anyone to find (and the private and password-protect features are not appropriate), this little feautre may reveal them to the public.

To remove the LINK data from the HEAD:
  1. First, pull up your template editor by going to Appearance >> Editor.
  2. On the right side is a list of files. Click on "Theme Functions" or "functions.php" to edit it.
  3. At the top, just after "<?php" add these lines of code:
    1. remove_action('wp_head', 'parent_post_rel_link', 10, 0);
    2. remove_action('wp_head', 'start_post_rel_link', 10, 0);
    3. remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
  4. Click "update file" at the bottom

All done! The link, rel="next" and rel="prev", as well as "start" and "parent", should be all gone from your template.

No comments: