Support

Account

Forum Replies Created

  • You are right, thanks again John for your expertise 🙂 Works perfectly

  • Thanks for your reply John.

    I can’t seem to get it to work. Was your code to fully replace what I had?

    Here is what I am trying to format the results of the relationship field…

    CPT 1
    – result 1
    – result 3
    – result 4

    CPT 2
    – result 2
    – result 6

    CPT 3
    – result 5

    etc etc..

    But because the user may pick the CPT in random order the results are grouped based on the order selected in the relationship field…

    CPT 1
    – result 1

    CPT 2
    – result 2

    CPT 1
    – result 3
    – result 4

    CPT 3
    – result 5

    CPT 2
    – result 6

    Hope this makes sense?

  • For anyone who runs into this with same issue, this solution worked for me based on Johns response here… link

    <?php  
      $found = false;
      $value = date('l');
      if( have_rows('opening_hour_settings', 'option') ) {
         while( have_rows('opening_hour_settings', 'option')) {
          the_row();
          $storeopen = get_sub_field('open_message');
          $storeclose = get_sub_field('closed_message');
          while( have_rows('opening_hours')) { the_row(); 
          if ($value == get_sub_field('day')) {
            $found = true;
            echo '<h5>' . $storeopen .'</h5>
            <ul class="opentimes">';
            //Loop through all opening times for that day
            while( have_rows('times') ): the_row();
            $open = get_sub_field('open_time');
            $close = get_sub_field('close_time');
            $times =  '<li>' . $open . '-' . $close . '</li>';
            echo $times;
            endwhile;
            echo '</ul>';
        //break loop to just display first result    
        break;
          }
        }
        }
    // end while have rows
      } // end if have rows
      if (!$found) {
        echo '<h5>' . $storeclose . '</h5>';
      }
    ?>
  • Hi John, thanks so much for your reply. I have read your articles and your possible solution above. I think I need to re-read a few times to try and get my brain around the concept. I think I get it and will try and put it into practice.

    Thanks again for your continued help, you’re a champ!!

  • Thanks John for your reply. I just wanted to check to see if there was a better way of setting up these relationships a bit more automatically which would make things faster and also cut back on input errors 🙂 Looking at my situation could you recommend a better way to achieve this?

  • I am having same issue, would love to know if you had any success with getting it to work?

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