Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    1

    Unanswered: Removing links from posts in wordpress

    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 (
    post_content,
    '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!

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    First step; filter the records to only those that contain the text you're looking for. Otherwise you're updating everything (even when no change is made).
    Code:
    ...
    WHERE  post_content LIKE '%dontneedlink.com%'
    Next step: assuming your content contains the examples you have provided
    Code:
    <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
    What do you want each line to look like when the update has completed?
    George
    Home | Blog

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •