Tagged: copy

Multisite Post Duplicator

Last post I mentioned a wee function I has written to help me with copying posts and pages from one multisite to another. Well I have packaged it into a plugin and submitted it to WordPress. After a few days I got notice that they approved it!


Check it out on GitHub also:

FireShot Capture - magicstickuk_multisi_ - https___github.com_magicstickuk_multisite-post-duplicator

It doesn’t finish here though. I have several ideas for future features. Stay tuned!


Multisite: Copy a Page From One Site to Another


I’ve been working on a multisite recently and my client requested something off the cuff that made me gulp. They said “I take it we will be able to copy a page from one site to the other to save us having to replicate it manually?”

Coping a page on the same site is pretty straightforward and there are a multitude of plugins out there that make it a pretty easy process. However. Doing this across a mulitsite is different. Not a lot of plugins out there.

wpmaz says*For this to work full with advanced custom fields you need to ensure your custom fields setup on both sites are the same!
I thought I would share a function I wrote today to achieve this. This is pretty basic at the moment but gives the core functionality and works with Advanced Custom Fields too*!

function duplicate_over_multisite($post_id_to_copy, $new_blog_id) {

    $post = get_post($post_id_to_copy);

    $title =  get_the_title($post);
    $post = array(

    	    // The new page title
            'post_title' => "Copy of" . $title,
            // Set the status of the new page
            'post_status' => 'draft',
            // The post type of this page
            'post_type' => 'page',
            // The user ID you want to assign to this page creation
            'post_author' => 1

    $data = get_post_custom($post);

    $meta_values = get_post_meta($post_id_to_copy);


    	$post_id = wp_insert_post( $post );
        foreach ( $data as $key => $values) {
            foreach ($values as $value) {
                add_post_meta( $post_id, $key, $value );

  	foreach ($meta_values as $key => $values) {
            foreach ($values as $value) {
                add_post_meta( $post_id, $key, $value );

     return $post_id;


I’m pretty happy with this, but think I might make a wee plugin for it!