Support

Account

Home Forums General Issues Getting values from rows of another posts

Solved

Getting values from rows of another posts

    • Juraj_

    • February 15, 2020 at 11:35 pm

    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.

    • Juraj_

    • February 16, 2020 at 3:17 am

    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.

    • Juraj_

    • February 16, 2020 at 5:35 am

    It works! Thank You 🙂

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.