Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Remove specific links

Remove specific links

Remove specific links

Hi to all,
I am not very good with mysql so i need some help.
I am trying to remove some specific links from my wordpress blog. I have a lot of outgoing links to several domains and i want to remove just links to one of them. For example all links that lead to dontneedlink.com or start with dontneedlink.com/(some child page)

I already try

UPDATE wp_posts SET post_content = REPLACE (
'Item to replace here',
Replacement text here');

But this is not god for me because I have a lot of key words and there is a lot of combinations.

So I need some kind of query to recognize my links that include dontneedlink.com and to remove href text and leave keyword untouched.

<a href=”http:// dontneedlink.com”>Test</a> -> Test
<a href=”http:// dontneedlink.com”>Test Again</a> -> Test Again
<a href=”http:// dontneedlink.com/childpage”>Test Again 2</a> -> Test Again 2

Is this possible at all?
This would save me a lot of time instead to go from one to another post and remove manually.

Thanks in advance!

RE: Remove specific links

You will need a 'Procedure' that will do a 'lookahead' when '<a' is encountered, check the URI and on a match, find the '>' and the '</a>' then remove everything between '<a' and '>' along with the '</a>', it's not particularly a simple task and certainly cannot be done in a simple UPDATE TABLE query.

You might have more luck finding a WordPress plugin that will strip specific links down to anchor text or write a theme function that parses the content before displaying it.


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close