• Hello

    I have a wordpress mu installation set up. I have the blogs in subdomains.

    blog1.wpsite.com
    blog2.wpsite.com
    blog…
    blog25.wpsite.com

    All of these blogs are related in that the pages are the same. Every blog has the same pages but not the same posts.

    When I add blog 26 I don’t want to have to slog through creating a couple dozen pages (all with templates). When I add a page I don’t want to have to go to all 25 blogs and add a page.

    So what I want to do is create a script that creates these pages on the fly.

    My question is
    what MySQL commands should I use to create a new page

    I tried this

    INSERT INTO wordpressmu.wp_<blog_num>_posts
    (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
     (2,'< date("Y-m-d h:i:s") >','<gmdate("Y-m-d h:i:s")>',
     '','<Page Title>', '', 'publish', 'closed', 'closed', '',
     '<Post Name>', '', '', '<date("Y-m-d h:i:s")>',
     '<gmdate("Y-m-d h:i:s")>',  '',  0, '<Post Name>/', 0,  'page', '', 0);";
    
    SELECT ID FROM wordpressmu.wp_<blog_num>_posts WHERE post_type = 'page' AND post_name='<Page Title>';
    
    INSERT INTO wordpressmu.wp_<blognum>_postmeta
            (post_id, meta_key,          meta_value) VALUES
            ($ID,       '_wp_page_template', '<template.php>'),
            ($ID,       '_edit_lock',        '".time()."'),
            ($ID,       '_edit_last',        '2');";

    The funny thing is that this worked for a couple blogs. But for most blogs the page existed in the wp-admin area but I got a 404 error when I tried to find it on the blog. Clicking the publish button from the wp-admin area would make the page appear. Is there something associated with apache mod_rewrite or something that I need to update as well so that wordpress knows that the page exists url-wise?

    Thank you

The topic ‘Creating wordpress pages with a script MySql Commands’ is closed to new replies.