The above will not work because the id conflicts with the regex pattern search.
The above will not work because the id conflicts with the regex pattern search.
Replace this:
$linkPattern = "/(<\s?a\shref\s?=[\s\"\'])($blogroll\/?)([\s\"\']{1,3})([^>]+)?(>)([^<]+)(<\/a>)/i";
with this:
$linkPattern = "/(<\s*?a\b[^>]*?\bhref\s*?=[\s\"\'])($blogroll\/?)([\s\"\']{1,3})([^>]+)?(>)([^<]+)(<\/a>)/i";
and it'll work
By the way, the problem wasn't outlined properly in my first post because I'd forgotten to place the code within WordPress' backticks.
Basically, the problem was that if you had any attributes—like an id—the regex pattern would not match.
So, this would work:
<a href="asdf.html" id="something">link</a>
…but this would not:
<a id="something" href="asdf.html">link</a>
Fixed in version 1.2. Thanks for the help.
You must log in to post.