Support

Account

Home Forums General Issues Getting values from rows of another posts

Solved

Getting values from rows of another posts

  • Hi,
    thank you for this awesome plugin!
    I have noticed some issues: I’m getting values from rows in another posts. It displays values from all rows in all posts in current post:

    <div class="col-lg-9 wow fadeInLeft delay-7">
    	<ul>
    
    	<?php
    	$args = array(
    		'post_type' => 'projekt',
    		'post_status' => 'publish',
    		'order' => 'ASC',
    		'posts_per_page' => '-1',
    	);
    
    	$myposts = get_posts( $args );
    
    	foreach ( $myposts as $post ) : setup_postdata( $post );	
    		if ( have_rows( 'proj-repeater_ocakavania' ) ) :
    			while ( have_rows( 'proj-repeater_ocakavania' ) ) : the_row();
    
    				$bod = get_sub_field( 'bod_ocakavania' );
    				echo '<li>' . $bod . '</li>';
    
    			endwhile;
    		endif; 
    	endforeach; 
    	?>				
    
    	</ul>
    </div>
    </div>

  • Yes, you are doing a query that gets all posts of the post type ‘projekt’ and you are looping over these posts so you will show every post, then for every post you are showing every row of the ‘proj-repeater_ocakavania’ repeater.

    If this is not what you want to do then you’ll need to explain what you want to do instead.

  • Thank You! I just want to display all rows from appropriate post on frontend. No more rows from another posts.

  • What template is this in? Is the query to get all of the posts necessary? If this template is already showing the current post then just eliminate the query and the loop over the posts so that you’re just doing the have_rows() loop.

  • It works! Thank You 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.