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"\">
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.
have you tried to use singe quote?? try this..
<img src='imge.jpg' alt='abcde fghij'>
PDO way of saving the data fixed this issue.
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.Thanking you.