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

The question:

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?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 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

Method 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.

Method 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.

Method 4

Just use Google’s Webmaster tools – it has a specific page showing internal links.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment