skip to Main Content

I’m racking my brain trying to think why this isn’t working. Seems to be right to me but I must be missing something.

<?php
    if( have_rows('cta_box') ):
        while( have_rows('cta_box') ) : the_row();
            echo get_sub_field('cta_header');
            echo get_sub_field('cta_content');
        endwhile;
    endif;
?>

enter image description here

enter image description here

Am I doing something dumb?
Thanks

3

Answers


  1. Chosen as BEST ANSWER

    Here is the code that got it working. Can someone explain? Is the code above this ACF effecting what is returned?

    <?php while ( have_posts() ) : the_post(); 
        $cta = get_field('state_call_to_action');
        echo $cta['call_to_action_heading'];
        echo $cta['call_to_action_body'];
    endwhile; ?>
    

  2. It’s a group field, not repeater. This’d help.

    So in your case you’d use it like this.

    $cta = get_field('cta_box');
    
    echo $cta['cta_header'];
    echo $cta ['cta_content];
    
    Login or Signup to reply.
  3. your code is proper, i think the issue is where you want to display like in the specific template or any where in the page, you just need to assign with the template or page or post whatever its will display.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search