Support

Account

Forum Replies Created

  • Hello,

    I knew the problem was coming from setup_postdata thing, I just didn’t know how to solve it. I used your code and everything’s now working !!

    Thank you very much !

  • Hello.

    I working on a similar problem for some hours now, I just can’t find the solution.
    I tried the code above, only the first repeater element is displayed, followed by weird posts, I dont even know where they came from.

    Here’s my code :
    // main query
    <?php $args = array (‘post_type’ => ‘newslettre’, ‘order’ => ‘DESC’,’posts_per_page’ => ‘1’, );
    $my_query= new WP_Query( $args );
    while ( $my_query->have_posts() ) : $my_query->the_post();

    // repeater
    if( have_rows(‘articles’) ):
    while ( have_rows(‘articles’) ) : the_row();
    $post_object = get_sub_field(‘choisir_un_article’);
    if( $post_object ):
    $temp_post = $post;

    foreach( $post_object as $post):
    setup_postdata($post);
    ?>

    // … do some stuff

    <?php endforeach;
    $post = $temp_post; ?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>

    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>

    Your hekl would be very appreciated !!!

    Thank you

  • I found a solution, I simply did not setup_postdata, so I don’t need to reset it ๐Ÿ™‚

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