Cloner did not copy custom post type

I just tried the Cloner plugin on multisite. Although I had all items selected to copy in settings - I am using a custom post type plugin called custom post widget that did not copy over. Note, I also use NBT for creating sites and the custom post types are copying over with it - just not in Cloner

  • antKat

    OK - after investigating this is what I found
    1. This is a network activated plugin and activating and deactivating plugin did not impact visibility.
    2. We do not give site owners access to pages - so we are using the content block (which they do have access) and then we insert a shortcode into the page. It is not the best method but it is working and copies over just fine with NBT.
    3. Using cloner did copy the content blocks but it generated different post ID than what is in the shortcode on the page and that is why the content is not displaying is the IDs do not match.

  • Vaughan

    Hi @antkat,

    I have just been discussing this with some colleagues, and this is confirmed, the post_id's are different on the cloned sites to the source.

    Which is why this is happening, I assume this will alos affect other plugins etc that might use shortcodes with post_id too.

    I will report this to the developer and see what/if anything can be done about this in an update, it could turn out to be a complex issue coding-wise to solve though, but hopefully the developer can look into it quickly.

    Thanks

  • Ignacio

    Hey @antKat

    I created a snippet to extend Cloner. You can get the code here: https://github.com/igmoweb/cloner-hacks/blob/master/plugins/custom-post-widget.php.

    You can follow instructions on how to add it to your site here (it's really easy): https://github.com/igmoweb/cloner-hacks

    But you'll need to add something to your current Cloner version, just change a line (don't worry, it will be present in the next version that I'm working on):

    1. Open the folloowing file: wp-content/plugins/cloner/copier/copier.php.
    2. In about line number 325 you should see the following line:

    do_action( "wpmudev_copier-copy-after_copying", $option['source_blog_id'], $option['user_id'], $option['template'] );

    3. Just replace it by this one:
    do_action( "wpmudev_copier-copy-after_copying", $option['source_blog_id'], $option['user_id'], $option, $option['template'] );

    Once you have everything setup, shortcodes and widget settings in Custom Post Widget should be remapped with the new IDs.

    Regards.
    Ignacio.