如何在 wp_posts 表中手动插入带有 html 代码的字符串 [英] how to manually insert string with html codes in wp_posts table

查看:35
本文介绍了如何在 wp_posts 表中手动插入带有 html 代码的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在迁移到 wordpress,需要手动将数据插入 wp_posts 表.在插入数据时,我使用的是 mysql_real_escape_string 但 html 属性被插入了额外的 \"示例:

I'm doing migration going to wordpress and needed manual inserting of data to wp_posts table. In inserting the data, I'm using mysql_real_escape_string but html attributes being inserted with additional \" example :

#Original
<img src="imge.jpg" alt="abcde fghij">

#Inserted to wp_posts using mysql_real_escape_string
<img src="\"imge.jpg"\" alt="\"abcde fghij"\">

这很糟糕,使图像无法正常工作.所以我需要关于如何以 wordpress 可接受的方式将数据插入 wp_posts.post_content 的帮助.

This is bad and makes the images not working. So I need help of how to insert data to wp_posts.post_content in a way that wordpress acceptable.

推荐答案


添加图片内容等需要使用此功能.


You need to use this function for adding the image content and other.

// Create post object
$my_post = array(
'post_title' => '#Enter the title#',
'post_content' => '#Enter the Content#'
,'post_status' => 'publish',
'post_author' => 1
);
wp_insert_post( $my_post );

它不会添加任何切片或其他任何东西.

It will not add any slice or anything else.

谢谢.

这篇关于如何在 wp_posts 表中手动插入带有 html 代码的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆