• Resolved Andreas 2013

    (@andreas-2013)


    Hello,

    I’ve created a custom post type “persons” and purchased WP All Import to import thousands of data from an old mysql table into wp_postmeta, to use them as custom fields. Unfortunately the wp_postmeta table has become very large and the performance to retrieve the data is very bad. It’s also very unsatisfying to get the data only via the two fields “meta_key” and “meta_value”.

    Therefore I would like to try to store and use the custom fields from a custom table. I’ve found the plugin “ACF Fields in custom table” to handle it. This plugin writes to the custom table only, when a wordpress post is saved. But there are 10.000 existing posts with persons, and I don’t want to save them manually again.

    Is there a way, that WP All Import can import my data (again) from the old table directly to the custom table, so that ACF respectively wordpress recognizes them correct as custom fields?

    Please note following post, I’ve found in the support of the mentioned plugin -> https://www.ads-software.com/support/topic/when-you-import-using-wp-all-import-all-the-acf-fields-show-up-empty/

    Thank you very much in advance for your help!

    Andreas

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Andreas 2013

    (@andreas-2013)

    Is there anybody, who could help me?

    Plugin Author WP All Import

    (@wpallimport)

    Hi @andreas-2013,

    My apologies for the delay.

    I had a look at the “ACF Fields in custom table” plugin and I can see that they’re using data from the $_POST variable to populate their custom table when the acf/save_post hook runs. The only way to make that work with WP All Import would be to write custom code that uses our API (see documentation) to:

    • Populate the $_POST variable with the data needed by the custom table plugin.
    • Trigger the acf/save_post action.

    Here is a rough example that you can modify as needed:

    function my_save_post( $id, $xml, $update ) {
    	$selector         = 'some_text_field';	
    	$text_field       = get_field_object( $selector, $id );
    	$text_field_value = get_post_meta( $id, $selector, true );
    	
    	$_POST['acf'] = array(
    		$text_field['key'] => $text_field_value
    	);
    	
    	do_action( 'acf/save_post', $id );	
    }
    add_action( 'pmxi_saved_post', 'my_save_post', 10, 3 );
    Thread Starter Andreas 2013

    (@andreas-2013)

    Hi,
    thank you very much for your help ??

    I will try it out!

    Plugin Author WP All Import

    (@wpallimport)

    Hey @andreas-2013,

    I’m going to mark this as resolved since it’s been inactive for a while. You can follow up in this thread if you have more questions about this.

    Anyone else, please open a new topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Import custom fields into custom table’ is closed to new replies.