Title: Import XML on theme activation.
Last modified: August 22, 2016

---

# Import XML on theme activation.

 *  [herowp](https://wordpress.org/support/users/herowp/)
 * (@herowp)
 * [12 years ago](https://wordpress.org/support/topic/import-xml-on-theme-activation/)
 * Hi guys. I have the function **seen bellow**, which I call on theme activation,
   using the **after_switch_theme** action:
 *     ```
       function herowp_importer_acf(){
       	global $wpdb;
   
       				if ( !defined('WP_LOAD_IMPORTERS') ) define('WP_LOAD_IMPORTERS', true); // we are loading importers
   
       				if ( ! class_exists( 'WP_Importer' ) ) { // if main importer class doesn't exist
       					$wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
       					include $wp_importer;
       				}
   
       				if ( ! class_exists('WP_Import') ) { // if WP importer doesn't exist
       					$wp_import = get_template_directory() . '/inc/plugins/importer/wordpress-importer.php';
       					include $wp_import;
       				}
   
       				if ( class_exists( 'WP_Importer' ) && class_exists( 'WP_Import' ) ) { // check for main import class and wp import class
   
       						$importer = new WP_Import();
   
       						$theme_xml = get_template_directory() . '/inc/dummy-data/xml/acf.xml.gz';
       						$importer->fetch_attachments = false;
       						ob_start();
       						$importer->import($theme_xml);
       						ob_end_clean();
       				}
   
       }
       add_action("after_switch_theme", "herowp_importer_theme_options");
       ```
   
 * but nothing imports. I double checked the xml file, and it’s all good. Any ideas?
 * Regards.

 The topic ‘Import XML on theme activation.’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [herowp](https://wordpress.org/support/users/herowp/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/import-xml-on-theme-activation/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
