Forked from tatianepires/tps-nav-menu-customization.php
Created
July 8, 2019 06:46
-
-
Save tdiphale/41f46d43e72078acb092d0d28b252d9d to your computer and use it in GitHub Desktop.
Revisions
-
tatianepires created this gist
Sep 17, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ <?php // Add class to A element of .primary-menu function tps_primary_menu_anchor_class($item_output, $item, $depth, $args) { $item_output = preg_replace('/<a /', '<a class="nav-link" ', $item_output, 1); return $item_output; } add_filter('walker_nav_menu_start_el', 'tps_primary_menu_anchor_class', 10, 4); // Add class to LI element of .primary-menu function tps_primary_menu_li_class($objects, $args) { foreach($objects as $key => $item) { $objects[$key]->classes[] = 'nav-item'; } return $objects; } add_filter('wp_nav_menu_objects', 'tps_primary_menu_li_class', 10, 2); ?>