WordPress.org

Ready to get started?Download WordPress

Forums

Search & Replace hack (6 posts)

  1. lunadust
    Member
    Posted 9 years ago #

    Hi I've been searching the Support Forum but don't seem to be able to find a hack to search and replace. Reason is my old links were absolute (i.e. http://example.com/blog/1.jpg) but I replace all the old links with relative path links (i.e. 1.jpg). Any ideas?

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    This would need you to run an sql query to do all the search/replace for you.

  3. kristin
    Member
    Posted 9 years ago #

    I had this problem when I moved my website from a subdomain to a top level domain.
    What I did was:
    Exported my database with phpMyAdmin (adding drop tables helps)
    Used find/replace in notepad to replace all of http://sub.example.com to http://www.newdomain.com
    Saved as a new file to keep my old database backed up just incase :)
    Used phpMyAdmin to import the modified sql file

  4. Anonymous
    Unregistered
    Posted 9 years ago #

    Is there anyone who can post the layout of such a query?
    I have on my site a lot of links to images on another server, since moving the site from a blogger-site hosted in a sub folder.
    example:
    http:/the_other_server.com/my_folder/img/image.jpg
    and I want those links to look like this:
    http://my_new_domain.com/img/image.jpg
    I. e. I want to change all occurrences of:
    http:/theotherserver.com/myfolder/
    to:
    http://my_new_domain.com/
    or better yet, just to point to my site root.
    Thanks
    Nick

  5. likoma
    Member
    Posted 9 years ago #

    Found this and it worked great:

    http://www.2020hindsight.org/2004/07/07/searching-and-replacing-within-phpmyadmin/

    It's basically this code in PHP MyAdmin, click SQL:

    update 01_posts set post_content = REPLACE(post_content, "what I want to replace", "the replacement text");

    I use numbers "01" instead of "wp" for my multiple installs, so make sure to change that prefix to the tables in question.

  6. glytch
    Member
    Posted 8 years ago #

    thanks for that! I needed a way to change the url from some remote hosted images to some locally hosted and this did the trick.
    it's a shame there isn't a mass search and replace plugin , or more likey it's a shame I couldn't find it! but now I now how to run queries on myphp so not a bad result.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.