Query to import data from one MultiSite table to another (pages/sub-pages)

I’m updating a standard install with about 500 (eek!!) pages to a MultiSite for easier sub-site management.

I basically want to take a sub-page and its children from the root site and copy the data to a new/fresh MultiSite-site.

Read More

The WordPress import/export option doesn’t work for this so I’ve had to do it using a MySQL query but I’m completely stumped?

The source table is ‘wp_posts’ destination is ‘wp_2_posts’, any ideas?

Related posts

Leave a Reply

1 comment

  1. OK So I worked this out. This query will do the trick of moving the pages:

       INSERT INTO wp_xxx_posts SELECT * FROM wp_posts WHERE post_parent IN
    
       (123,456,789,1011);
    

    The xxx relates to the destination MultiSite ID (wp_3_posts for example).

    The (numbers) in brackets are the parent ID’s (‘post_parent’ in the WP table) of
    the pages I wanted to import. In this example I imported about 20
    pages and there were 2 levels of hierarchy.

    The only issue was when the pages are moved no meta data comes over so
    things like templates, page order and page parent options in the WP
    dashboard are a bit off. I fixed this by doing a MASS EDIT in the WP dashboard.

    Basically select all pages (select all, choose ‘edit’) and changed the page parent to be a newly created page on the new site. This worked but I had to re-build my page structure.

    Anyway, this works if anyone cares to try it 🙂 its not perfect because of the meta but it works for me!