0

I'm creating an event page where we can add an event line-up. Such a line-up consists out of different speakers.

So I've create two custom post types:

  • Line-up
  • Speaker

On my event page you can select the created line-up. A repeater is used to add speakers (speaker post objects) to a specific line-up.

On my event page:

<?php
   /*
    * get the ID of the selected line-up
   */

   $line_up = get_sub_field('line-up');
   $line_up_id = $line_up->ID;
?>

        

<?php
/*
 * Looping over the speakers repeater within the selected line-up
*/
if( have_rows('speakers', $line_up_id) ):
    while( have_rows('speakers') ) : the_row();
        $speaker_obj = get_sub_field('speaker_object');
        $speaker_time = get_sub_field('speaker_time');
                    
        var_dump($speaker_obj); // there is no output
                    

    endwhile;
endif;
?>

But there is no output.

3
  • You can't use dashes in PHP variables. $line-up is not valid PHP. Try replacing them with underscores and see if that resolves the issue. Mar 3 at 13:15
  • That was a typo caused my copying it to stackoverflow. I've edited the example above.
    – Dennis
    Mar 3 at 13:18
  • @Dennis this is an ACF question, so it should not be asked here. And I just wanted to say that your 2nd have_rows() call is missing the $line_up_id, so that might be the cause to the issue. But if not, then you should ask on SO or an ACF support forum/site for further help/insights.
    – Sally CJ
    Mar 3 at 14:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.