Last active
October 27, 2016 23:58
-
-
Save anisotropy/42927ea52aac0c036ae6f5482b7bff02 to your computer and use it in GitHub Desktop.
워드프레스: 특정한 문자열이 포함된 제목을 가진 포스트들을 구하고 그 포스트들의 내용을 변경
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 | |
$keyword = 'something'; | |
global $wpdb; | |
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_title LIKE '%keyword%'"); | |
foreach($posts as $p){ | |
$id = $p->ID; | |
$title = $p->post_title; | |
$content = $p->post_content; | |
wp_update_post(array( | |
'ID' => $id, | |
'post_title' => 'changed: '.$title, | |
'post_content' => 'changed: '.$content | |
)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment