È estremamente facile spostare il vostro sito WordPress utilizzando un plugin di backup. Ma se voleste spostare solo un tipo di post personalizzato? In questo articolo vi mostreremo come importare ed esportare tipi di post personalizzati in WordPress. Vi mostreremo anche come importare le tassonomie personalizzate associate ai vostri tipi di post.
L’esportazione e l’importazione di un tipo di post personalizzato in WordPress richiedono due passaggi. La prima fase prevede la migrazione del tipo di post personalizzato e delle tassonomie. Il secondo passo consiste nell’importare i dati del tipo di post.
Spesso i tipi di post personalizzati in WordPress sono associati a tassonomie personalizzate. Vi mostreremo come esportare/importare le tassonomie personalizzate insieme al tipo di post.
Esportazione di tipi di post e tassonomie personalizzate in WordPress
Alcuni utenti preferiscono creare i loro tipi di post e tassonomie personalizzati aggiungendo del codice nel file functions.php del loro tema o in un plugin specifico per il sito. In questo caso, è sufficiente copiare il codice e incollarlo sul sito in cui si desidera importarli.
Tuttavia, in alcuni casi potrebbe non essere possibile individuare il codice. Non preoccupatevi, potete comunque creare lo stesso tipo di post personalizzato sul nuovo sito.
Tutto ciò che occorre sapere è il valore della chiave del post. Si tratta del nome utilizzato per il tipo di post nel database di WordPress. È possibile trovarlo semplicemente visitando il tipo di post nell’area di amministrazione di WordPress.
Una volta ottenuta la chiave del post, visitate il sito in cui volete importare il tipo di post e utilizzate il plugin Custom Post Types UI per creare il vostro tipo di post personalizzato.
È anche possibile ottenere la chiave della tassonomia personalizzata semplicemente visualizzando la tassonomia personalizzata nell’area di amministrazione.
Utilizzare il plugin CPT UI per creare la stessa tassonomia sul sito di destinazione in cui si desidera importare la tassonomia.
Ripetere la procedura per tutti i tipi di post personalizzati e le tassonomie che si desidera importare.
Suggerimento bonus: se avete usato il plugin CPT UI per creare i vostri tipi di post, potete usarlo anche per migrarli. Ma questo funziona solo se il tipo di post personalizzato originale è stato creato con questo plugin. Visitare la sezione Importazione/Esportazione nelle impostazioni del plugin e seguire le istruzioni sullo schermo.
Tipi di post personalizzati e tassonomie create dai plugin
Molti dei più diffusi plugin di WordPress utilizzano tipi di post e tassonomie personalizzate per gestire tipi di contenuti personalizzati. Ad esempio, Soliloquy li usa per creare slider, i plugin eCommere li usano per creare prodotti, ecc.
Se si vuole continuare a usare questi plugin, non è necessario importare i CPT. È sufficiente installare il plugin sul sito di destinazione per avere a disposizione i tipi di post e le tassonomie personalizzate.
Molti di questi plugin sono dotati di funzioni di importazione/esportazione, ma se un plugin non dispone di questa funzione, è comunque possibile esportare i dati.
Esportare/importare i dati dei tipi di post e delle tassonomie personalizzate in WordPress
WordPress è dotato di un potente strumento di importazione/esportazione che consente di esportare e importare i dati di WordPress. Basta andare su Strumenti ” Esportazione.
Vedrete elencati tutti i vostri tipi di post. Selezionare i tipi di post che si desidera esportare e premere il pulsante Scarica file di esportazione.
WordPress preparerà un file di esportazione XML e il browser inizierà a scaricarlo.
Ora passate al sito di destinazione dove volete importare questi dati. Andate su Strumenti ” Importazione. Verrà visualizzata una serie di opzioni, fare clic su WordPress.
Si aprirà un popup che vi chiederà di installare il plugin WordPress importer. Fare clic sul pulsante di installazione e poi su Attiva plugin ed esegui importatore.
Nella schermata dell’importatore, è necessario fare clic sul pulsante Scegli file e selezionare il file XML scaricato in precedenza. Quindi, fare clic sul pulsante Carica file ed esporta.
WordPress importerà ora i dati dei tipi di post personalizzati. Verranno importati tutti i tipi di post personalizzati selezionati in precedenza. WordPress aggiungerà automaticamente i termini alle tassonomie personalizzate.
Questo è tutto, speriamo che questo articolo vi abbia aiutato a importare ed esportare tipi di post e tassonomie personalizzate in WordPress.
Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per i video tutorial su WordPress. Potete trovarci anche su Twitter e Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Kerry says
I am trying to export CPT data, but the WP export tool doesn’t list the CPT. I’m using the CPT UI plugin. Any help?
WPBeginner Support says
For that specific plugin, you would want to check under CPT UI, Tools and you should see that plugin’s specific method for importing and exporting post types.
Admin
Bulut says
There are people, Trouble Maker
There are Bloggers, Trouble Eraser
Thanks guys. You saved my day and time!
WPBeginner Support says
Glad our guide was helpful
Admin
Gabriela says
Hi!
We are switching themes – we want a new site basically – hopefully with a cleaner backend. The switch is from a custom-built theme to a new theme.
Would it be best to install a new theme within our same back end, or would it be cleaner to export and import into a new backend?
Raf says
Clear incoherence between title and intent and practical advises:
1) says “Exporting Custom Post Types and Taxonomies in WordPress”
2) says “in some cases you may not be able to locate the code.”
3) says “Don’t worry you can still create the same custom post type on the new site.”
So if the post-type is created using the UI : you can not export it but only create it again. Why the article doesn’t clearly state it?
Francis says
So let say for instance if I was using a paid plugin that has to do with custom posts and want to switch to the free version how will i go about it? Am still very new to wordpress
stefano says
Hi, can I ask you what plugin do you use for the social share?
thanks
WPBeginner Support says
Hi Stefano,
We use custom code written specifically for our own use.
Admin
David says
How can you export and have the option of exporting by month like you have when you export post and page?
charles says
When exporting custom post types it doesn’t export the featured image url path. Any idea how to resolve this?
Amy says
Can I export a custom type type and import it as a different post type? Is that possible?
Paul says
I’m trying to do this too, which is why I landed here. I’m trying to rename a custom post type without losing the post data. Not having much luck.
Jhony Penagos says
Thank you !! It work for me.
Chris says
Does related custom field data get packaged with the custom post type export?
Carlitos says
It does not. you will want to bring that over either in your functions file or enter it in manually if you are using a plugin.
Jim D says
Is this something you would need to do if you are using a custom post type currently and wish to switch to a different theme?
WPBeginner Support says
It depends on how you created the custom post types in the first place. If these custom post types were created by your old theme then you will need to export them before switching theme. If the custom post types were created using a plugin then they would remain unaffected when you switch the theme. Lastly, if you created the custom post type by adding code into your theme’s functions file then you just need to copy that code and paste it in your new theme.
Admin
Philip Downer says
This article should have a bit of clarification. As Kris touched on, you can only import a custom post type if that specific custom post type actually exists on the destination site. You’ll need to either export and include the code that registers the post type; or if you’re using a plugin to handle custom post types, you’ll need to ensure that the same settings are used.
WPBeginner Support says
If you take a look at the article, the first section is about duplicating the CPT to the site where you want to import CPT data.
Admin
Kris says
Not to forget: themes also make their own custom post types (portfolio for example). Not only moving a site, but also switching themes can also be difficult
I ended up coding the post type and taxonomies in a separate site-specific plugin with the aid of generatewp.com; I was surprised how easy it went and found it less confusing then CPT-UI
Sophia says
What does importing and exporting custom post types do? Sorry, I’m such a newb.
WPBeginner Support says
It comes in handy when you specifically want to move content from a custom post type to another site.
Admin