WordPress.org

Ready to get started?Download WordPress

Forums

searching the source (11 posts)

  1. stopthepress
    Member
    Posted 8 years ago #

    Does anyone have any idea on how to search the content source? let's say you need to find and replace a given tag in all your posts and pages, how do you do that?

    By the way, I tried to search the word "search" in this forum and....
    Tatatata! The result is really funny. :)

  2. Kafkaesqui

    Posted 8 years ago #

    "Tatatata!"

    You said wanted to search the "source," didn't ya? ;)

    To do what you want would require going direct to the database. If you access yours using a tool like phpMyAdmin, the interface makes it fairly easy to search a specific field in a table. Search and replace is a little more complicated, though. For example, when I swapped out <br> for <br /> in my older posts, I used this SQL query statement:

    UPDATE wp_posts SET post_content = REPLACE(post_content, '<br>', '<br />');

    The MySQL resource page on REPLACE:

    http://dev.mysql.com/doc/mysql/en/replace.html

    EDIT: Forgot to note that it's always a smart move to backup (i.e. export) your database before making any sort of changes to it. Better safe than...you know.

  3. stopthepress
    Member
    Posted 8 years ago #

    Kafkaesqui,
    What I'm looking for is something practical, even easy to revert and without dealing with MySQL.

  4. Mark (podz)
    Support Maven
    Posted 8 years ago #

    The only other way is to export your database, open the file in a decent editor, run a search/replace the import the result.

  5. moshu
    Member
    Posted 8 years ago #

    ... need to find and replace a given tag...
    It might also depend on what kind of tag?

  6. stopthepress
    Member
    Posted 8 years ago #

    Actually need to replace a


    by
    <br clear="left" />
    and a
    " />-
    by
    " align="left" hspace="5"/>-
    ignoring spaces.

    Will try the procedure suggested by Podz. Hopping for the best and planning for the worse.

  7. Kafkaesqui

    Posted 8 years ago #

    Just remember whatever way you go, you'll be dealing with MySQL to one degree or another. Really no way around it (if you know what I mean).

  8. leMaxim
    Member
    Posted 8 years ago #

    Wow...what does happen when you search for 'search' - why do I get a css file?

    SECURITY GLITCH?!

  9. Kafkaesqui

    Posted 8 years ago #

    "SECURITY GLITCH?!"

    If our passwords were hiding in that file, I'd agree. But you're just dropped into a css file. Hardly a breach, but definitely a bug.

  10. stopthepress
    Member
    Posted 8 years ago #

    "Just remember whatever way you go, you'll be dealing with MySQL "

    I did test both methods. Whew! No problem, but it was just a test. Will wait until weekend to fight that battle. Still I wish some sort of coded source search.

  11. stopthepress
    Member
    Posted 8 years ago #

    "SECURITY GLITCH?!"

    I thought it was an Easter egg ;) Where is my prize?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.