Skip to content

Commit

Permalink
Merge pull request #15 from justinkruit/main
Browse files Browse the repository at this point in the history
Add active class to "current_page_parent" and "current-post-ancestor"
  • Loading branch information
AlexWebLab authored Aug 6, 2021
2 parents 1ea7c1f + ee00881 commit 5247d9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function start_el(&$output, $item, $depth = 0, $args = null, $id = 0)
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';

$active_class = ($item->current || $item->current_item_ancestor) ? 'active' : '';
$active_class = ($item->current || $item->current_item_ancestor || in_array("current_page_parent", $item->classes, true) || in_array("current-post-ancestor", $item->classes, true)) ? 'active' : '';
$nav_link_class = ( $depth > 0 ) ? 'dropdown-item ' : 'nav-link ';
$attributes .= ( $args->walker->has_children ) ? ' class="'. $nav_link_class . $active_class . ' dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="'. $nav_link_class . $active_class . '"';

Expand Down

0 comments on commit 5247d9e

Please sign in to comment.