Inserting Posts via External Script
-
I have a hundreds of pages I’d like to setup in a WordPress site. I’m trying to create a php command-line script I can use to parse through the data and create pages. The data changes regularly, so I need to automate things.
Obviously, I should use the WP functions instead of directly using the MySQL tables. The following script runs without error…but no page is created ??
Any pointers on what I’m doing wrong?
#!/usr/local/php5/bin/php <?php include ('/some/path/wordpress/wp-admin/admin.php'); include ('/some/path/wordpress/wp-includes/post.php'); $to_insert = array(); $to_insert['post_author'] = 0; $to_insert['post_content_filtered'] = '<h1>Here is my info</h1>\n<ul><li>one</li><li>two</li></ul>\n'; $to_insert['post_type'] = 'page'; $to_insert['post_title'] = 'We Must Test'; wp_insert_post($to_insert);
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Inserting Posts via External Script’ is closed to new replies.