WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to have sort of a functionality that will let me find all internal links on my site that are pointing to a page. i.e - I want to know all pages on my site that are linking to (any) page in my site. I tried to find sort of a ready made plugin for that, but didn't seem to find. I can develop one by myself, but I wonder what will be the best way to have such functionality. Any ideas will be very welcomed . Thanks

share|improve this question
up vote 0 down vote accepted

Post Search Approach

  1. Pull out all of your posts and pages from the database
  2. Iterate through all pages / posts and do a string search on the content - substr_count( 'http://www.yourdomain.com', $page->content );
  3. Sum up the counts from all the posts / pages

This will of course miss allot of links made by plugins, navigation etc - hence "half-ass".

Site Scraping Approach

  1. Collect all the URLs you want to count links from
  2. Iterate through the URL list and use file_get_contents( $the_url ) to get the page / post as a string
  3. Perform the string search described above and sum them all up

This approach will double count the links persistent through many pages (navigation and sidebars).

There is, I'm sure a much better way to do this - but that's all I could come up with off the top of my head. I'm sure you could tweak either approach to suit the degree of coverage you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.