• Resolved kearo

    (@kearo)


    Hi!

    I can’t figure out if I can do it with All Import or All Import Pro.

    What I need:

    I have a CSV file structured in such a way that all the data is on a new row.
    For example:
    Row1: name1 – phone1 – address1
    Row2: name1 – phone1 – address2

    The unique identifier is Name1 (I map it onto the title), i.e. I need only one post with Name1 title.

    When I create new posts or update them via the Importer, I need it to append a new address to the existing one.

    In other words, I need to add new content, and not update all of it.

    Can I do that? If yes, how?

    I’ve seen here that I can’t do it. But why? It’s really that simple. Just append new data to the chosen fields. In my case it’s the Content field

Viewing 1 replies (of 1 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @kearo

    In my case it’s the Content field

    To append content from multiple import records into 1 post you’d have to write some custom code that uses our API to do it. Please see this hook: https://github.com/soflyy/wp-all-import-action-reference/blob/master/all-import/pmxi_article_data.php.

    Here’s an example snippet that you can modify as needed:

    function my_pmxi_article_data( $articleData, $import, $post_to_update, $current_xml_node ) {
    	$new_data = $post_to_update->post_content;
    	if ( ! empty( $new_data ) ) {
    		$new_data .= PHP_EOL . PHP_EOL . $articleData['post_content'];
    		$articleData['post_content'] = $new_data;
    	}
        return $articleData;
    }
    add_filter( 'pmxi_article_data', 'my_pmxi_article_data', 10, 4 );
Viewing 1 replies (of 1 total)
  • The topic ‘Append new content to existing posts’ is closed to new replies.