• Resolved timmx

    (@timmx)


    Hi!

    I’m struggling with displaying my ACF Repeater field into single CDATA rows.

    This is what i would like to achieve:

    <countries>
    <![CDATA[ Botswana ]]>
    <![CDATA[ Zimbabwe ]]>
    </countries>

    Currently, it’s displaying like this:
    <countries>
    <![CDATA[ a:1:{s:4:”land”;s:17:”Botswana|Zimbabwe”;} ]]>
    </countries>

    I’ve tried writing multiple functions:

    <countries>
    [my_output_items({Landen})]
    </countries>

    <?php
    function my_output_items( $landen ) {
    	$pieces = explode("|", $landen);
    	echo "value: " . $pieces[1] . " ]]>";
    }
    ?>

    This returns the following value (on top of the page):
    value: Zimbabwe ]]>

    So, i feel like i’m getting there, but i really need some help to get further with this. Any advice is highly appreciated.

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

    (@wpallimport)

    Hi @timmx,

    I’m struggling with displaying my ACF Repeater field into single CDATA rows.

    You’ll probably have to adjust it, but here’s an example function that should give you an idea of how to tackle this:

    function my_output_items( $countries ) {
    	$xml = '';
    	$countries = maybe_unserialize( $countries );
    	if ( empty( $countries ) ) return $xml;
    	$extracted_countries = reset( $countries );
    	$extracted_countries = explode( '|', $extracted_countries );
    	
    	$xml = "CDATABEGIN";
    	foreach ( $extracted_countries as $country ) {
    		$xml .= "{$country}".PHP_EOL;
    	}
    	$xml .= "CDATACLOSE";
    	return $xml;	
    }
    Plugin Author WP All Import

    (@wpallimport)

    Hi @timmx,

    I’m marking this as resolved since we haven’t heard back in a while. Feel free to open a new topic if you still have questions.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Export Repeater field to single CDATA rows’ is closed to new replies.