• I have a custom field for a custom post type with a link to an image in it. I need to append that link with a new directory. Here’s an example: the field has “photoname.jpg” in it and I need to change it to “/wp-content/agent-photos/photoname.jpg”. The photo name needs to be a variable or a wildcard, because each post has a different photo name.

    I tried to do this with a SQL query first, but I couldn’t figure out how to use a variable or wildcard. I ended up with this and it didn’t work.
    UPDATE w211_postmeta SET meta_value = replace(meta_value, ‘%’, ‘/wp-content/agent-photos/%’) WHERE meta_key LIKE ‘wpcf-agent-photo’

    I’m not familiar with wp functions yet so I tried to find a plugin. I found the Search & Replace plugin, but I could I didn’t seen an option for appending a field instead of replacing it’s content.

  • The topic ‘Batch find and append post meta’ is closed to new replies.