I'm pretty new to Wordpress, ACF and PHP.

I am currently working on a project, the website has 11 different sports centres all with different sport/activities, on each centre they will have a sidebar listing through all indoor, outdoor sports and the different swimming activities. As seen in the image below.

image of the side bar

The first Issue I have is that although swimming is selected on the radio button it still comes though on the indoor sports box. (My sports are children of the sports page, there will be more than one ID needed when i push to staging so if theres a way to do it without ID that would be a lot better)

Here is it selected: [swimming page2

And here is the code i'm using to get it:

$sport_categories = get_field('sport_location');

       $childArgs = array('sort_order' => 'ASC', 'sort_column' => 'menu_order', 'child_of' => 498);
   $childList = get_pages($childArgs);
      foreach ($childList as $child) { ?>
      <?php if($sport_categories == 'Indoor Sports'): ?>
         <a href="<?php the_permalink()?>"><?php echo $child->post_title; ?></a>
      <?php elseif($sport_categories != 'Indoor Sports'): ?>   
   <?php endif; ?>
<?php } ?>

Here is my acf radio button too: radio button acf

My second issue

Although the code does pull the name into all child pages of sport it is not shown on any of the other pages of the centre.

My pages goes as follows:

  • Centre
    • Sports
      • sub page i.e swimming
      • sub page i.e Tennis
      • sub page i.e Football
    • Timetables
    • Facilities
    • Opening Times
    • Contact Us

I need to show the sidebar and its content on all of the centres children.

I hope i have explained my issue with enough detail, if you need anything else please let me know.

Thank you in advance!!


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.