• Hi,

    I am testing creating new pages from script on a multisite installation. I’ve had a google into how to go about this and am mostly using the info from this previous forum post:

    http://ww.wp.xz.cn/support/topic/inserting-posts-via-external-script

    my code looks like:

    <?php
    
    //      error_reporting(E_ALL); //
            ini_set('display_errors', '1');
            ini_set('display_startup_errors',1);
            error_reporting(-1);
    
    echo 'starting script';//
    
            include ('/usr/local/www3/wp-admin/load-scripts.php');
    //        include ('/usr/local/www3/wp-admin/admin.php');
            include ('/usr/local/www3/wp-includes/post.php');
         //   include ('/usr/local/www3/wp-load.php');
    //        include ('/usr/local/www3/wp-blog-header.php');
            include ('/usr/local/www3/wp-includes/ms-blogs.php');
    //        include ('/usr/local/www3/wp-includes/functions.php');
    //        include ('/usr/local/www3/wp-content/themes/mc/functions.php');
    echo 'starting script';//
    
            $wpdb->set_blog_id(15);
    
    //-- Set up post values
                    $myPost = array(
                            'post_status' => 'publish',
                            'post_type' => 'page',
                            'post_author' => 0,
                            'post_title' => 'Test Post',
                            'comment_status' => 'closed',
                            'ping_status' => 'closed',
                    );
    
    echo 'new post array defined, now create new post';
                    //-- Create the new post
                    $newPostID = wp_insert_post($myPost);
    
    ?>

    This is returning no error and exits with status 0. Any “echo” I put in for debugging after the includes section is not executed. Probably I’m doing something basic wrong, can anyone help at all?

    thanks in advance, Andy.

Viewing 1 replies (of 1 total)
  • Thread Starter andybrna

    (@andybrna)

    Is it worth my while trying to debug this script or is there any reason I shouldn’t just bypass the wordpress code all together and access the DB directly? Ie use Perl to do a bulk update of the DB…

Viewing 1 replies (of 1 total)

The topic ‘Add post/page from script problem’ is closed to new replies.