• Resolved ttmt

    (@ttmt)


    Hi all

    Another realtionship question sorry

    I have a custom post type for testimonials.

    The custom post has a testimonial_image, testimonial_text and testimonial_link, that are also CFS fields

    I’m using a relationship field ‘the_testimonial’ to select one of the testimonial posts on the home page.

    This is all working and I can select a post and echo the title of this post.

    <?php
    
    	$values = $cfs->get('the_testimonial');
    
    	foreach ($values as $post_id) {
    
    		echo '<div class="well">';
    
    	    $the_post = get_post($post_id);
    
    	    echo '<h2>' .$the_post->post_title. '</h2>';
    
    	    echo '<p>'. $the_post-> get('testimonial_text').'</p>';
    
    	    echo '</div>';
    	}
    
    ?>

    How can I display the other fields fron the testimonial, like the testimonial_text, testimonial_text and testimonial_link.

    https://wordpress.org/plugins/custom-field-suite/

Viewing 1 replies (of 1 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    Within the foreach loop, pass $post_id into the second parameter of get():

    echo CFS()->get( 'testimonial_text', $post_id );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Get post field using Relationship field’ is closed to new replies.