Support

Account

Home Forums Add-ons Repeater Field Pulling in a repeater field, into a post object repeater field

Solved

Pulling in a repeater field, into a post object repeater field

  • Hello,

    I have an issue that I am trying to solve but have seemed to hit a wall on. Here is the scenario.

    I have a repeater field on my home page that is a post object so the user can choose what posts they want to display on the home page. Within the post objects (the posts that I select in my post object repeater field) I have another repeater field that I need to pull in. I grabbed some code in another forum and was trying to make it work.

    My home page repeater field is named “featured_solutions’
    the repeater field in the post that I am trying to pull in is called ‘product_size’
    and that repeater field’s sub field is called ‘pipe_size’

    I have others, but if I could come up with a solution for one I can reuse that for the other repeater fields that I have.

    Any help wit this would be greatly appreicated!

    `<?php

    if(have_rows(‘featured_solutions’)){

    while (have_rows(‘featured_solutions’)) {
    the_row();

    $featured_sol = get_sub_field(‘featured_solution’);
    if($featured_sol){

    $fsolimage = get_field(‘page_thumbnail’, $featured_sol->ID);
    $fsollink = get_permalink($featured_sol->ID);
    $fsoltitle = get_the_title($featured_sol->ID);
    $fsolsummary = get_field(‘application_summary’ , $featured_sol->ID);
    //$fsolsizes = get_sub_field(‘pipe_size’ , $featured_sol->ID);
    $fsolsizes = get_field(‘product_size’ , $featured_sol->ID);
    $pipesize = get_sub_field(‘pipe_size’ , $featured_sol->ID);
    $fsolapprovals = get_field(‘product_approval’ , $featured_sol->ID);
    $applications = get_the_terms( $featured_sol->ID, ‘taxonomy’ );

    if($fsolsizes) {
    while (has_sub_field(‘product_size’)) {
    echo ‘

    • ‘ . $pipesize . ‘

    ‘;
    }
    }

    }

    echo ‘<div class=”solutionItem”>
    <div class=”siImage” style=”background-image:url(‘ . $fsolimage . ‘);”><h3 class=””>’ . $fsoltitle . ‘</h3></div>
    <div class=”siPad”>
    <div class=”siCopy”>
    <div class=”siTop”>
    <span>Applications</span>
    ‘ . $applications->name . ‘
    </div>
    <div class=”siLeft”>
    <span>Sizes</span>
    ‘ . $pipesize . ‘
    </div>
    <div class=”siRight”>
    <span>Approvals</span>
    ‘ . $fsolapprovals . ‘
    </div>
    <div class=”breakline”></div>
    <div class=”siCTA”>
    <div class=”ctabutton primary”>learn more</div>
    </div>
    </div>
    </div>
    </div> ‘ ;

    }

    }
    ?>

  • This seems to work, might be a bit bloated for now, but it is working properly

    <?php 
    		
    if(have_rows('featured_solutions')){
    	
    	while (have_rows('featured_solutions')) {
    		the_row();
    		
    		$featured_sol = get_sub_field('featured_solution');
    		if($featured_sol){
    			
    			$fsolimage = get_field('page_thumbnail', $featured_sol->ID);
    			$fsollink = get_permalink($featured_sol->ID);
    			$fsoltitle = get_the_title($featured_sol->ID);
    			//$fsolsizes = get_field('product_size' , $featured_sol->ID);
    			//$pipesize = get_sub_field('pipe_size' , $featured_sol->ID);
    			//$fsoapproval = get_sub_field('approval' , $featured_sol->ID);
    			//$fsolapprovals = get_field('product_approval' , $featured_sol->ID , $fsoapproval[0]);
    			
    		}
    		
    			
    		
    		
    		echo '<div class="solutionItem">
                    <div class="siImage" style="background-image:url(' . $fsolimage . ');"><h3 class="">' . $fsoltitle . '</h3></div>
                    <div class="siPad">
                        <div class="siCopy">
                            <div class="siTop">
                                <span>Applications</span>
    							<p>';
                                $categories = wp_get_post_categories( $featured_sol->ID , array('child_of' => 10 ));
    							//loop through them
    							foreach($categories as $c){
    							  $cat = get_category( $c );
    							  //get the name of the category
    							  $cat_id = get_cat_ID( $cat->name );
    							  //make a list item containing a link to the category
    							  $applications = $cat->name;
    							  echo $applications. '<br />';
    							}
                           echo '</p>
    						</div>
                            <div class="siLeft">
                                <span>Sizes</span>
    							<p>';
                                if(get_field('product_size' , $featured_sol->ID)){
    								while(has_sub_field('product_size' , $featured_sol->ID)){
    									echo the_sub_field('pipe_size' , $featured_sol->ID) . '<br />';
    									}
    								}
                            echo '</p>
    						</div>
                            <div class="siRight">
                                <span>Approvals</span>
    							<p>';
                                if(get_field('product_approval' , $featured_sol->ID)){
    								while(has_sub_field('product_approval' , $featured_sol->ID)){
    									echo the_sub_field('approval' , $featured_sol->ID) . '<br />';
    									}
    								}
                            echo '</p>
    						</div>
                            <div class="breakline"></div>
                            <div class="siCTA">
                                <div class="ctabutton primary"><a href="' . $fsollink . '">learn more</a></div>
                            </div>
                        </div>
                    </div>
                </div> ' ;
    		
    	}	
    	
    } 
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Pulling in a repeater field, into a post object repeater field’ is closed to new replies.