最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

I want to update my postcontent with $wpdb

programmeradmin0浏览0评论

When I post a post to my site though webapi,there already had a same post_title in my post list, So I just want to update my post_content or replace all data to the old post but not let wp create a new post which post_name became post_name-1.

I got this code with wpdb, but it's not work, please help me, thank you guys!

$checkTitle = true;    
if($checkTitle)
            {
        $post_title = trim(hm_strip_slashes($post_title));
        $sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_title` = '$post_title'";
        $t_row = $wpdb->query($sql);
        if($t_row) {$wpdb->get_results("update $wpdb->posts set `post_content` = $post_content WHERE `post_title` = $post_title");};
            }
发布评论

评论列表(0)

  1. 暂无评论