Category hierarchy destroyed by cloning

Hi there,

I just used cloner to create a clone of a multisite site and have had a few problems, the main one is that the category hierarchy got screwed up in the cloned site...

What appears to have happened is that the categories got put in alphabetical order such that category id 1 became 'Al's Blog' and Uncategorised became category id 15- this would be fine except that now when I view my categories in the back end most of them dont show up and 'sub categories' dont show up on the front end of my site any more and the default category gets automatically set to 'Als blog' rather than Uncategorised...

Additionally my site uses plugins that attach styles on post id and category id (so that individual categories or posts can be styled), so changing either of these also really screws things up for me, so is there anyway that Cloner could clone a site and keep the post and category ids intact? In fact I'd be interested to know why its a bad idea or impossibility for all ids, for anything really (menus, widgets etc), to be kept intact (assuming this is a bad idea for some reason) since I am sure lots of plugins make references to these things...

Looking forward to your feedback

David

  • Michael Bissett

    Hey @davidosullivan, hope you're doing well this evening! :slight_smile:

    First off, I noticed that your Multisite isn't up to date presently, and I'm curious as to whether that might be affecting things? Could you try updating that please, and try again?

    Should it still act up after doing that, I'd like to have a closer look at how you have things set up here, could you enable Support Access to your Multisite please, and mention the site on the network that you're trying to clone? :slight_smile:

    Please advise,
    Michael

  • davidosullivan

    Ahh ok well the plugin wont really work for me anyway then since as I say, styles and layouts are related to the post, menu and category ids. I'll have to look into that and see if I can hook into your plugin some way and re-create the attachment tables based on the new ids...

    Is there any reason why ID's are not preserved- could we expect this in a future update? Its just if this maybe forthcoming, there would be little point in me creating a hook in...

    Thanks for finding out for me though :wink:

  • davidosullivan

    Thanks for doing that Ash,
    From what I see when looking through lots of code in plugins, lots do use the post ID in some fashion, maybe not as extensively as I am, but the post id is something the user cannot change, so stuff that is attached to that stays attached to it regardless of how extensively the user changes any of the content.

    You could get around this by changing every instance of everything that refers to that number, but every plugin would have to be accounted for by hand, which is probably infeasible realistically, so keeping the ids intact- or providing the option to do so would I think be a cleaner safer option.

    Should the developer come back to you with reasons why this would be a bad idea, I'd really appreciate if you could add that information to the thread since it would be very useful for me as a developer :slight_smile:

  • Ignacio

    Hi @davidosullivan.

    First of all, sorry for the delay here but I've been really busy in the last days.

    The reason because we don't preserve terms IDs is because, well, WordPress functions do not allow us to do that. Cloner is made based on native WordPress functions. This way, the plugin is much better integrated with WP and we get many less errors while copying stuff.

    It's strange, but WP allows to preserve posts IDs but not terms, don't know why.

    Fortunately, Cloner is very extensible with lots of hooks so you can use them to change your plugins settings when they are pointing to a term. I would be more than happy to provide you a solution for your plugins or at least to give you a piece of code to start with.

    Regards.
    Ignacio.

  • davidosullivan

    Sorry Ignacio, hadn't read your previous post... but I see you say there that WP will allow you to retain post IDs which is great as hopefully this will include 'nav_menu_items' and anything else which resides in the posts table too (like attachments)...

    Then its just widgets, which to be honest I have not tested thoroughly as yet, so these maybe ok anyway...

    Looking promising :slight_smile: good stuff!

  • Ignacio

    Hi @davidosullivan

    I just released a new version of the plugin, could you test it a bit? Terms should be inserted preserving IDs. Posts, pages, etc were inserted with the same ID time ago.

    About menus: They are one of the most difficult things to copy. It would need a lerge amount of new code and could casue more issues so for the moment, the plugin cannot include that feature.

    That said, Cloner tries to replace the menus IDs in the menu widgets so that should work anyway. If you have another widget that uses menus IDs I could proveide you a solution for that if you tell me which plugin are you using.

    Regards.
    Ignacuio