Migrate Ads images in Classipress

Update: If you only need to export your ads to CSV/Excel, we recommend you to use this plugin:

Export Ads CSV

 

When you try to migrate all the content from one ClassiPress based website to another, there is a known problem that does not allow you to export/import the ads images. In a full content migration context with a lot Ads this could be a big problem because you must upload the images for every ad manually after migration done.

Here, we show a simple workaround to migrate all your content between two ClassPress sites, including all the ads images.

1. Go to your current CP site and select Tools>Export

2. Select to export All content:

3. Then, press ‘Download Export file’. This will generate an XML file

4. Now, we need to make a simple WP mod in our destination site to force WP to import all the attachments, to do that, we need to modify the file: wp-admin/includes/import.php adding only two lines of code:

    // Save the data
	$id = wp_insert_attachment( $object, $file );
	// BEGIN PATCH TO ALLOW IMPORT CLASSIPRESS ADS IMAGES
    $attach_data = wp_generate_attachment_metadata($id, $file);
	wp_update_attachment_metadata($id, $attach_data);
    // END PATCH
  

5. Finally, it’s time to import the content into our new site. To do that, we need to go into our destination site Tools>Import>.