使用此插件在父级上添加链接
<?php
/*
Plugin Name: Menu Link
Description: Quick Custom Solution Plugin for Implementing Custom Solution.
Version: 1.0.0
Author: Rohit Kauhsik
Author URI: https://in.linkedin.com/in/rohit-kaushik-108a2383
License: GNU General Public License (Version 2 - GPLv2)
*/
function custom_nav_menu_link_attributes( $atts, $item, $args ){
if ( !wp_is_mobile() && $args->has_children ) {
$atts[\'href\'] = ! empty( $item->url ) ? $item->url : \'\';
}
return $atts;
}
add_filter( \'nav_menu_link_attributes\', \'custom_nav_menu_link_attributes\', 99, 3 );
function func_make_menu_clickable(){
if ( !wp_is_mobile() ) { ?>
<script type="text/javascript">
jQuery(document).ready(function($){
if($(window).width() >= 767){
$(\'li.menu-item a\').click(function(){
window.location = $(this).attr(\'href\');
});
}
});
</script>
<style type="text/css">
@media all and (min-width: 767px) {
.menu-item-has-children:hover > ul {
display: block;
}
}
</style>
<?php }
}
add_action(\'wp_footer\', \'func_make_menu_clickable\', 1);