Trying to display advanced custom fields information only yields empty results

I’m trying to display a food menu created via Advanced Custom Fields Pro, however when I try to display the information from the fields I get nowhere despite doing it a lot of times in the past. I’ve been going over the code a bunch of times but I can’t find what’s wrong with it..

My structure of the fields look like this:

Read More

structure of fields

The top image is what it looks like when creating the information. The other two is the name of the fields, which are days and the sub field is called days_day, I got 5 sub fields, one for each day of the week.

Then I try to display this info via this script:

<ul id="food-menu-content" class="clearfix no-bullet-list">

<?php
  $args = array(
    'post_type' => 'meny'
  );

  $menu_query = new WP_Query( $args );
?>
<?php if ( $menu_query->have_posts() ) : while ( $menu_query->have_posts() ) : $menu_query->the_post(); ?>

  <?php if ( have_rows('days') ) : while ( have_rows('days') ) : the_row(); ?>

    <?php if ( have_rows('days_day' ) ) : while ( have_rows( 'days_day' ) ) : the_row(); ?>

      <li>
        <h3><?php the_sub_field('days_day'); ?></h3>
      </li>

    <?php endwhile; endif; ?> <!-- have_rows('days_day') -->

  <?php endwhile; endif; ?> <!-- have_rows('days') -->

<?php endwhile; endif; ?> <!-- $menu_query -->

</ul>

The fields are connected to a custom post type called “meny” which I run my own WP_Query on and then I try and access the information from the fields during the current iteration.

Problem with this script is that I only get one li from the loop and it’s completely empty of information. When really I should get 5 since I have 5 sub fields (days_day).

What is wrong here?

Related posts

Leave a Reply