• Hi there,

    I need to replace active payment link URL in all WP posts with another.

    Anchor of the URL I want to leave the same, just change url A to url B.

    I’ve tried SQL request in PHPMyadmin:

    UPDATE wp_posts SET post_content = replace(post_content, ‘A’, ‘B’);

    It says: Matched rows: 0

    I’ve tried Search and Replace plugin – it has found only 1 url.

    Can someone advice what should be done to do that?

    Thank you.

    • This topic was modified 1 year, 11 months ago by Aeroshield.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    It’s possible that the SQL query you’re using isn’t finding any matches because it’s looking for an exact match for the string ‘A’ within the post_content field. If the URL you’re trying to replace has additional parameters or formatting, the query may not be able to find it. Would be good to double-check it.

    Have you had any luck using the WP-CLI Search Replace? Or tried using the Better Search Replace plugin?

    And make sure to back up your database before making any changes to your content, just in case something goes wrong during the search and replace process.

    Thread Starter Aeroshield

    (@alex7xl)

    Thank you for the reply.

    Yes, I tried Better Search Replace plugin with no luck ??

    My URL that is need to find and replace has lot of additional parameters and looks like:

    https://domainA.com/buynow/checkout?sku3422292=1&storeid=788820&language=ENGLISH&forceDesktop=y&storecardvisible=N&companylogovisible=n

    May be you know how to deal with such type of long URL?

    Moderator bcworkz

    (@bcworkz)

    Considering the difficulty you have in finding such URLs, I suspect they are dynamically generated from disparate elements. Perhaps what you should do is find the code that actually outputs the URL and work backwards into what other functions are called to construct the URL. Ideally, somewhere along the line you’ll encounter a suitable filter where you would be able to alter what you need to alter.

    Alternately, maybe you could output buffer the related HTML, then alter the buffer content prior to echoing it out.

    Thread Starter Aeroshield

    (@alex7xl)

    Thank you for the idea. I will try that ??

    Alex (Aeroshield)

    • This reply was modified 1 year, 11 months ago by bcworkz.
    Moderator bcworkz

    (@bcworkz)

    You’re welcome.

    Please do not place links in any kind of signature. (or self promotional links anywhere. One in your profile is all that’s allowed) It’s seen as spam and will cause you to seen as a spammer. Signatures are generally discouraged, though a simple informal name with no additional information is acceptable.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Replace url in all WP posts to another’ is closed to new replies.