Created
September 28, 2013 05:28
-
-
Save johnbocook/6738693 to your computer and use it in GitHub Desktop.
Find and replace custom field data in wordpress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
find_replace_custom_field_data( $post_ID = NULL, $custom_field_name = NULL, $search_for = NULL, $replace_with = NULL ) { | |
if ( isset( $post_ID ) && isset( $custom_field_name ) ) | |
$get_ custom_field = get_post_meta( $post_ID, $custom_field_name, TRUE ); | |
$custom_field_new = str_replace( $search_for, $replace_with, custom_field ); | |
set_post_meta( $post_ID, $custom_field_new );` | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment