Copying taxonomies and metadata

Hi all,

We run a network of sites and we would like to be able to copy posts, custom post types, taxonomies and their meta data across from one blog to the another in the network. This plugin seems to do just that, but I have two questions:

1. Will it copy custom taxonomies and post meta?
2. Are there actions and filters to link into to process the post meta (link images, etc) and taxonomy meta (we make quite extensive use of this and it is non-standard, so we will need to do our own processing).

Thanks in advance.

  • Vaughan

    Hi @developerscc,

    That's a good question, I can't say for sure whether it will do custom taxonomies, however if they are using the standard WP functions & coding standards then it should work fine.

    With regards to the actions & filters, I will need to ask the developer for some feedback on this for you, could you perhaps explain a bit more of the non-standard processing that you do, it might help the developer if he knew more of the process you are wanting to do.

    Hope this helps

  • developerscc

    Thanks for you quick response! To help understand what we are hoping to achieve I'll give a scenario:

    We have a custom post type with a number of custom taxonomies. One of the taxonomies is called location. This taxonomy has meta data associated to it like an image, address and geolocation. To attach this data to the taxonomy we use a metadata plugin. It would be great if there were some hooks that would fire once a source taxonomy is read and once the new taxonomies are written. This would enable us to read the metadata and copy it once the new term is added.

    Another scenario is that we have a custom post type with additional images and files associated to it. These images and files are standard WordPress attachments and are stored as IDs in the metadata. We obviously don't just want to copy IDs which have no meaning on a new blog. We want to actually copy the attachments (if this is not already done by the plugin) and re-associate the right attachment on the new blog. Some actions fired once a post is read and inserted on the new blog would enable us to achieve this.

    I hope this helps. Really hoping this is possible!

    Thanks again!

  • Ignacio

    Hi @developerscc.

    The plugin copies all the terms to the new blog but it won't copy the metada that you're talking about. Obviously we cannot predict how every system works so you'll need to add some code. There's an action that fires up when a new term is copied:

    do_action( 'mcc_term_copied', $source_term_id, $destination_term, $source_blog_id );

    You could use it this way (more or less ):

    add_action( 'mcc_term_copied', 'my_custom_function', 10, 3 );
    function my_custom_function( $source_term_id, $destination_term, $source_blog_id ) {
    	// When this action executes, we are on the blog where we want to copy the terms.
    	$current_blog_id = get_current_blog_id();
    	switch_to_blog( $source_blog_id );
    	// Here is where you get the term metadata with $source_term_id
    	$term_metadata = function_that_gets_term_metadata( $source_term_id );
    	// now is the moment to copy all that  metadata to the destination blog
    	function_that_insert_term_metadata( $destination_term['term_id'], $term_metadata );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.