gpt4 book ai didi

javascript - Wordpress 上的 jQuery Superfish 菜单不显示

转载 作者:行者123 更新时间:2023-11-28 08:49:50 25 4
gpt4 key购买 nike

我正在开发 jQuery“Superfish”下拉菜单(Wordpress)。我使用最新版本的 superfish 和 wordpress。问题是,superfish 让我的菜单不可见...我什么也看不到我的菜单...

functions.php

//Register Superfish
///////////////////////////////////////////////////////////

add_action( 'wp_enqueue_scripts', 'superfish_libs' );
function superfish_libs()
{
// Register each script, setting appropriate dependencies
wp_register_script('hoverintent', get_template_directory_uri() . '/superfish-js/hoverIntent.js');
wp_register_script('bgiframe', get_template_directory_uri() . '/superfish-js/jquery.bgiframe.min.js');
wp_register_script('superfish', get_template_directory_uri() . '/superfish-js/superfish.js', array( 'jquery', 'hoverintent', 'bgiframe' ));
wp_register_script('supersubs', get_template_directory_uri() . '/superfish-js/supersubs.js', array( 'superfish' ));

// Enqueue supersubs, we don't need to enqueue any others in this case, as the dependencies take care of it for us
wp_enqueue_script('supersubs');

// Register each style, setting appropriate dependencies
wp_register_style('superfishbase', get_template_directory_uri() . '/superfish-css/superfish.css');
wp_register_style('superfishvert', get_template_directory_uri() . '/superfish-css/superfish-vertical.css', array( 'superfishbase' ));
wp_register_style('superfishnavbar', get_template_directory_uri() . '/superfish-css/superfish-navbar.css', array( 'superfishvert' ));

// Enqueue superfishnavbar, we don't need to enqueue any others in this case either, as the dependencies take care of it
wp_enqueue_style('superfishnavbar');
}

//Register jQuery 1.1.3
///////////////////////////////////////////////////////////

wp_deregister_script('jquery');
if(!is_admin()) {
wp_register_script('jquery', get_template_directory_uri() . '/js/jquery-1.1.3.js');
wp_enqueue_script('jquery');
}

header.php

<div id="wrapper-mainnav">

<div class="left"></div>
<div class="content">
<?php wp_nav_menu(array('theme_location' => 'mainnav', 'menu_class' => 'sf-menu')); ?>
</div>
<div class="right"></div>

<br class="clearer">

<div class="bottom"></div>

</div><!--wrapper-mainnav-->

请帮忙,我找不到错误...请告诉我,如果您需要更多信息...

最佳答案

首先,don't dequeue WordPress bundled jQuery .

添加类sf-menu似乎有点困难到<ul>容器。它被应用于鞋面<div> .
我在 wp_nav_menu 中尝试了多种参数变体没有效果。

一个简单的解决方案是手动更改它

$mainnav = wp_nav_menu(array('theme_location' => 'mainnav', 'echo' => false );
echo str_replace( '<ul>', '<ul class="sf-menu">', $mainnav );

关于javascript - Wordpress 上的 jQuery Superfish 菜单不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19303714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com