karlherrick.com

Post via script

Friday, 12 March 2010

I just whipped up some PHP and threw it in the root of a brand new WordPress 2.9.2 install:

include_once('wp-config.php');
include_once('wp-load.php');
include_once('wp-includes/wp-db.php');

$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;

wp_insert_post( $my_post );

Voila. The post appeared when navigating to the .php file.

See: http://codex.wordpress.org/Function_Reference/wp_insert_post.

For more creativity, get into the database: http://codex.wordpress.org/Function_Reference/wpdb_Class


Home

About

Portfolio

Web Apps Web Enabled Applications Corporate Sites Personal Sites
Preferences Dark Theme Light Theme Notifications
Social GitHub LinkedIn RSS Feed Icon