How do I check if I linked to a post before I delete it?

If I want to “safely” delete a post. I want to make sure that no link exists (within my blog) to “to-be-deleted” post. How do I do that?

Related posts

Leave a Reply

4 comments

  1. After reading this thread I saw that I might need this also sometimes. So here is the result:

    The internal link checker plugin

    It adds a meta box at your post edit screens that shows links to all posts who link internally to the currently displayed post. If you want to alter the output (add something for eg.), please use the provided filter. An example of how to use the filter can be found at the readme file.

    The Plugin is GPL2 licensed. Maybe I’ll also put it in the official repo to allow installation from inside your self hosted blog. Edit: Done.

    …or at…

    …or in our own

  2. You can do a query like:

    SELECT ID, post_title, post_date, post_content 
    FROM wp_posts 
    WHERE post_content 
    LIKE '%your-post-title%' ORDER BY post_date
    

    to get all posts that linked that old post order by date.

  3. There is no separate table or data structure that keeps post-to-post links, so the best way to do this is to search your posts for the URL of the post you want to delete. The search works on the HTML code of the post, so it will contain the full link, even if you don’t see it in the visual editor.

    Of course, you should also search through the pages, since they can also contain links to posts.

    Another approach would be to use Google. If you search for link:http://example.com/2011/05/post-to-delete/ it will return all pages that link there. You can then also add site:example.com to limit the results to only pages on your site. Of course, this will not be as up-to-date as a search in your own current database.