Page no: Y23
Table of contents
Replace External Article Links by Links to Syndicated Content
problem
The most important syndication tool is the replacement of external links into internal links. When David Andalfatto talks about an article by Noah Smith, then he will link Noah’s page on Noah’s blog.
Unfortunately this link is outside of our site and we risk to lose traffic and google points. But we have syndicated Noah’s blog entry on our site.
Solution Idea
With our syndication plugin, we have stored also the original external link in a meta attribute. So we have a mapping from internal page/link to external link (in meta).
Now we should replace the external links with internal ones.
Selection of posts and pages
See this page for the GUI and selection of posts and pages.
Make the chunk process
The “chunk process” is the loop through all posts, pages and books that got selected in the GUI.
There is an “inner loop” that goes through all posts and pages and find out, if we can replace an external with an internal link.
During this operation we load a selected chunk of items.
We prepare the real execution of the changing. After the first step, here we have the number of the internal links in this article, which can be replaced. This task is for the real execution of the prepared links.
Make the replace
Once a link is found, we must start the replace. We use the command “preg_replace”. The code for the replace looks as follows:
Here we prepare the content of the article to get all of the URLs from the article and search for similar link into Original Link field (wp posts meta)
Statistics
Then we have to check how much URLs are changed and to give back the stats to the GUI.
Improvements
See more for