Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Pinoss on "Insert a Post in Wp_post MYSQL"

$
0
0

Hi,
I need to insert some posts and pages into wp_post database with Php code directly. Now the code it's working but I would to insert a Shortcode in the Content of generated post (this shortcode is generated by Shortcode Exec PHP plugin and contains some php lines) . The problem is that when I enter to generated post, the output is : [shortcode]? and not : Hello World (if, for example, the shortocode is echo "Hello World";

I'm using this code:

<?php
$ip = 'myserver';
$user = 'mydatabaseuser';
$password = 'mypass';
$db_name = 'mydatabsename';
$conn = mysql_pconnect($ip,$user,$password) or die();
$error = mysql_select_db($db_name,$conn) or die();

$data="INSERT INTO mydatabsename.wp_posts (ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) VALUES ('1202', '0', '2014-09-14 00:00:00', '2014-09-14 00:00:00', '[shortcode]', 'test', 'test', 'publish', 'open', 'open', '', 'test', '', '', '2014-09-14 02:06:11', '2014-09-14 05:21:26', '', '0', '', '0', 'post', '', '0');";

$result_data=mysql_query($data,$conn);

echo "inserted!";

?>

I tried to insert Posts with "wp_insert_post" native function but allways generates duplicates posts in database.

How Can I solve this issue? Wich method is better to insert posts/pages manually in wp_post database?

Thanks in advance.


Viewing all articles
Browse latest Browse all 8245

Trending Articles