Skip to content

Instantly share code, notes, and snippets.

@malebolgia
Last active August 29, 2015 14:07
Show Gist options
  • Save malebolgia/070a6e51022a1133d7f9 to your computer and use it in GitHub Desktop.
Save malebolgia/070a6e51022a1133d7f9 to your computer and use it in GitHub Desktop.
Wordpress
if ( $args->has_children && $depth === 0 ) {
// $atts['href'] = '#';
$atts['href'] = ! empty( $item->url ) ? $item->url : ''; //use link instead of pragma link
$atts['data-toggle'] = 'dropdown';
$atts['class'] = 'dropdown-toggle disabled'; // add disabled to this part so e.preventdefault will be override
} else {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
}
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
@malebolgia
Copy link
Author

navwalker.php -> here you make the nav main link work with URL linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment