• Resolved Nox

    (@profnox)


    [ Moderator note: moved to Fixing WordPress. Please do not use Developing with WordPress for these topics. ]

    Hi,

    I’m in charge of importing a lot of HTML files (with HTML import 2) in order to convert an old static website into a WordPress one.
    The problem is they contain links with domain and subdomain that we want to replace by news permalinks. I think the best solution to do that is to replace the old hard links by new links (hard too).

    I though about doing a kind of str_replace(‘href=”keyword’, ‘href=”keyword2’, $content) on all posts in a row. But I don’t know at all how to handle that : I think that the best solution should be passing by a custom bulk action, but, how to get the raw content of a post (with the tag <a href="...">and replace it, also save this new content in the database ?

    I wonder if it was possible.

    PS: I know what you’ll say : “Why don’t you change all those hard link directly in a text editor like Atom which can replace a string in all files of an entiere project in a row ?” Unfortunately, I have to use HTTrack to get the HTML files of the old website (which is very old and was managed with Lotus), and it doesn’t get the files in UTF8 so, if I open the files and save them with a text editor, it will replace all special chars by “?” icons and destruct all the content…

    Thank you in advance,
    Sincerely yours,

    Profnox.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change hard link in all post content ?’ is closed to new replies.