Skip to content

Instantly share code, notes, and snippets.

@wickywills
Created January 15, 2020 08:34
Show Gist options
  • Save wickywills/98e5c145d42f8ff944a575f5a4526b13 to your computer and use it in GitHub Desktop.
Save wickywills/98e5c145d42f8ff944a575f5a4526b13 to your computer and use it in GitHub Desktop.
Add this to a general include or functions file somewhere
```
// Get current page name and use that to highlight current page in menu
$current_page = basename($_SERVER['PHP_SELF'], ".php");
```
Then add this to your links:
```
<li class="<?php echo $current_page == 'about' ? 'active' : ''; ?>"><a class="menu-about" href="about">about</a></li>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment