Home Forums Add-ons Repeater Field Move content from repeater to the_content


Move content from repeater to the_content

  • Hi all,
    I’m pulling in post_content from several page to make a tabbed section but one page is made up of a ACF repeater field.

    This is what I have that’s pulling in the content

    	$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'asc' ) );
    	foreach( $mypages as $page ) {
    		$content = $page->post_content;
    		if ( ! $content ) // Check for empty page
    		$content = apply_filters( 'the_content', $content );
    		<div class="<?php echo $page->post_name; ?>">
    			<h2><?php echo $page->post_title; ?></h2>
    			<?php echo $content; ?>
    <?php } ?>

    and then I have this in it’s own template

    <?php if( have_rows('blood_components') ): ?>
    	<?php while( have_rows('blood_components') ): the_row();
    		// vars
    		$image = get_sub_field('image');
    		$content = get_sub_field('text');
    		<div class="bc">
    			<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
    				<?php echo $content; ?>
    	<?php endwhile; ?>
    <?php endif; ?>

    I found

    function add_my_custom_field($data) {
        // _FIELD_NAME_HERE_ should be replaced with the custom field name.
        $data .= esc_html( get_field('_FIELD_NAME_HERE_'));
        return $data;

    but wasn’t sure how to make that work with the repeater field.

    Thanks in advance for the help!

Viewing 1 post (of 1 total)

The topic ‘Move content from repeater to the_content’ is closed to new replies.