FF Import & Export

  • Name : FF Import & Export
  • Version : 2.1.7
  • File : Login to download file

Changelog:

v.2.1.6
* fixed acf fields missing on select phase when first item doesn't have those fields

v2.1.3
* added support for acf file field

v2.1.2
* fixed post metas not included on import

v2.1.1
* fixed other acf fields not included on import

v2.1.0
* added support for nested terms

Settings page at Tools > FF Export / FF ImportĀ 

Export

Ffie 1
  • Date filters
  • Offset = useful for splitting/batching
Ffie 2
  • Featured image will get the post featured image/thumbnail url
  • Option to include all post meta or specific metas, enter each meta key in the textbox, 1 item per line
  • Include ACF fields
  • Include specific taxonomies/terms
  • Preview option useful to check if all the data you need is included
Ffie 3

Extending Export (for devs)

Add custom type by hooking into "ff_export_types" filter

				
					add_filter( 'ff_export_types', function( $types ){
    $types['custom_1'] = 'Custom 1';
    return $types;
});
				
			

The custom type should show up under select type dropdown

Ffie 4

Processing the custom type - hook into the filter "ff_export_data_{custom_slug}"

				
					add_filter( 'ff_export_data_{custom_slug}', function( $items, $ff_export ){
    
    // store the items in the $items array
    // $ff_export is the class instance that contains helpful methods, you can check all the methods at export/class-export.php

    // codes here ...

    return $items;
}, 10, 2 );

				
			

sample codes:

				
					add_filter( 'ff_export_data_custom_1', function( $items, $ff_export ){

    $args = [
        'post_type' => 'property',
        'showposts' => -1,
    ];

    $q = new WP_Query($args);

    foreach( $q->posts as $post ) {

        $item = [
            'post_data' => $post,
        ];

        // featured image
        $item['featured_image'] = $ff_export->get_featured_image_url($post->ID);

        // acf fields
        $item['acf_fields'] = $ff_export->get_acf_fields( $post->ID );

        // all post meta
        $item['post_metas'] = get_post_meta($post->ID);

        // taxonomies
        $taxonomies = [
            'custom_category',
            'property_cat',
        ];
        $item['taxonomies'] = $ff_export->get_taxonomy_terms( $post->ID, $taxonomies );

        $items[] = $item;
    }

    return $items;

}, 10, 2 );
				
			

Import

Ffie 5
  • Select the post type you want to map to
  • Select / Upload the json file from the export
  • Items to process per batch is set to 1 to avoid 502 or server timeouts, downloading images can cause this. If there is no images on your import, you can increase this number to process more items quicker.
  • Select the data you want to include
Ffie 6
  • Option to map post metas (Map meta key field)
  • ACF Post Objects and Relationship fields needs additional mapping to the post type, or if just want to save the post title select “Title Only” under Map post type
  • Option to map taxomies/terms

Extending Import (for devs)

Add custom type by hooking into "ff_import_custom_types" filter

				
					add_filter( 'ff_import_custom_types', function( $types ){
    $types['custom_1'] = 'Custom 1';
    return $types;
});
				
			

A new tab “Custom” will show up, the custom type should be under the select type dropdown

Ffie 8

Processing the custom type - hook into the action "ff_import_data_{custom_slug}"

				
					add_action('ff_import_data_{custom_slug}', function($item, $ff_import){
    // $item contains the data for each individual item - check the preview to see what it looks like
    // $ff_import is the class instance that contains helpful methods, you can check all the methods at import/class-import.php
    // codes here...
}, 10, 2);
				
			

Sample Codes:

				
					add_action('ff_import_data_custom_1', function($item, $ff_import){    

    $post_type = 'property';
    $post_title = $item['post_data']['post_title'];

    // check if post exists
    $post_id = $ff_import->get_post_id( $post_title, $post_type );
    if( !$post_id ) {
        // create new post
        $post_id = wp_insert_post([
            'post_title' => $post_title,
            'post_status' => 'publish',
            'post_type' => $post_type,
        ]);
    }

    if( !$post_id ) return;

    // upload featured image
    $ff_import->update_post_thumbnail( $post_id, $item['featured_image'] );

    // post metas
    $metas = [];

    // image / gallery
    // get image ids, upload new images
    // string of single image url OR array of image urls
    $img_ids = $ff_import->get_image_ids( SINGLE_IMAGE_URL_OR_ARRAY_OF_IMAGES );
    if( $img_ids ) {
        $metas['META_KEY_HERE'] = $img_ids;
    }

    // post objects
    $map_to_post_type = 'post';
    // string of single post title OR array of post titles
    $post_object_ids = $ff_import->get_post_ids_from_title( POST_TITLE_OR_ARRAY_OF_POST_TITLES, $map_to_post_type );
    if( $post_object_ids ) {
        $metas['META_KEY_HERE'] = $post_object_ids;
    }

    // save post metas
    $ff_import->update_post_metas( $post_id, $metas );

    // taxonomies / terms
    $terms = ARRAY_OF_TERM_NAMES_HERE;
    $map_to_taxonomy = 'category';
    $append = true; // true = add | false = replace existing
    $ff_import->assign_terms( $post_id, $terms, $map_to_taxonomy, $append );

}, 10, 2);
				
			

Share This

Select your desired option below to share a direct link to this page.
Your friends or family will thank you later.