Skip to main content
- removed unnecessary php end tag; moved endforeach above closing </ul> as it would cause layout issues; made the if in the first li tag a shorthand if for legibility
Source Link

When you use endforeach;, you have to use : instead off { when starting the foreach.

    <ul class="project-extension-side-link">
    <?php foreach($projectextensions as $projectextension) : // <--- ?> 
        <li <?php ifecho ($section=='project-extension')
   ? 'class="active"': {echo''); 'class="active"';}?>><span>Project 1</span></li>
        <li><a href=""><?php echo $projectextension->post_title; ?></a></li>
        <li><a href="">Project 3</a></li>
        <li><a href="">Project 4</a></li>
        <li><a href="">Project 5</a></li>
        <li><a href="">Project 6</a></li>
      </ul>

   <?php endforeach; ?>
</ul>   <?php}?> 

Greetz Bjorn

When you use endforeach;, you have to use : instead off { when starting the foreach.

    <ul class="project-extension-side-link">
   <?php foreach($projectextensions as $projectextension) : // <--- ?> 
    <li <?php if($section=='project-extension')
     {echo 'class="active"';}>><span>Project 1</span></li>
        <li><a href=""><?php echo $projectextension->post_title; ?></a></li>
        <li><a href="">Project 3</a></li>
        <li><a href="">Project 4</a></li>
        <li><a href="">Project 5</a></li>
        <li><a href="">Project 6</a></li>
      </ul>

   <?php endforeach;?>
   <?php}?>

Greetz Bjorn

When you use endforeach;, you have to use : instead off { when starting the foreach.

<ul class="project-extension-side-link">
    <?php foreach($projectextensions as $projectextension) : // <--- ?> 
        <li <?php echo ($section=='project-extension' ? 'class="active"': ''); ?>><span>Project 1</span></li>
        <li><a href=""><?php echo $projectextension->post_title; ?></a></li>
        <li><a href="">Project 3</a></li>
        <li><a href="">Project 4</a></li>
        <li><a href="">Project 5</a></li>
        <li><a href="">Project 6</a></li>
    <?php endforeach; ?>
</ul>    

Greetz Bjorn

Source Link
Bjorn
  • 535
  • 4
  • 10

When you use endforeach;, you have to use : instead off { when starting the foreach.

    <ul class="project-extension-side-link">
   <?php foreach($projectextensions as $projectextension) : // <--- ?> 
    <li <?php if($section=='project-extension')
     {echo 'class="active"';}>><span>Project 1</span></li>
        <li><a href=""><?php echo $projectextension->post_title; ?></a></li>
        <li><a href="">Project 3</a></li>
        <li><a href="">Project 4</a></li>
        <li><a href="">Project 5</a></li>
        <li><a href="">Project 6</a></li>
      </ul>

   <?php endforeach;?>
   <?php}?>

Greetz Bjorn