Created
March 18, 2021 22:20
-
-
Save bacoords/b70ed9b50e9134c4dc37fde6cf31789e to your computer and use it in GitHub Desktop.
All dropdown to be links when using the bootstrap nav walked or under strap theme.
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 characters
<?php | |
/** | |
* Allow | |
* | |
* @param [type] $atts | |
* @param [type] $item | |
* @param [type] $args | |
* @param [type] $depth | |
* @return void | |
*/ | |
function bc_set_link_href_for_dropdowns( $atts, $item, $args, $depth ) { | |
if ( isset( $atts['class'] ) && 'dropdown-toggle nav-link' == $atts['class'] ) { | |
$atts['href'] = ! empty( $item->url ) ? $item->url : '#'; | |
} | |
return $atts; | |
} | |
add_filter( 'nav_menu_link_attributes', 'bc_set_link_href_for_dropdowns', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment