• Hi all,

    I’m writing a plug-in for my site that replaces (or adds if it is empty) a value of the custom field based on the value of another custom field under the same post.

    Example:
    I will have a list with comma divided values like that:

    apple,red
    banana,yellow
    kiwi,green
    etc.

    When I run the script, it will find a post with custom_field_fruit where its value is “apple” and will change custom_field_color’s value to red, in the same post, of course. Then, it will process the second line of the list and find a post with custom_field_fruit = banana and will change custom_field_color = yellow, etc.

    So, I need help with the hard part. I have two variables $VALUE1 and $VALUE2 (fruit,color). Do I need to run a mySQL query to replace fields?

    If so, can someone translate this to mySQL?
    Find a post where custom_field_fruit is $VALUE1 and replace the value of custom_field_color with $VALUE2 under the same post.

    Thank you.

  • The topic ‘Replace value of the custom field based on the value of another custom field’ is closed to new replies.