使用jQuery在wordpress中发布菜单系统
你好,我有一个问题,我希望有人能帮助我。我在wordpress中设置了一个滑动菜单系统,适用于所有主页。我的问题是,当我点击博客页面上的“更多”按钮进入全文时,我的菜单停止工作 这是一张图片,上面是工作菜单和地址,下面是破损的菜单和地址 我知道这与编码有关,我已经尝试了我能想到的一切。我需要它来设置一个类的“选定”的博客李当它进入完整的文章页面 功能代码:使用jQuery在wordpress中发布菜单系统,jquery,wordpress,menu,Jquery,Wordpress,Menu,你好,我有一个问题,我希望有人能帮助我。我在wordpress中设置了一个滑动菜单系统,适用于所有主页。我的问题是,当我点击博客页面上的“更多”按钮进入全文时,我的菜单停止工作 这是一张图片,上面是工作菜单和地址,下面是破损的菜单和地址 我知道这与编码有关,我已经尝试了我能想到的一切。我需要它来设置一个类的“选定”的博客李当它进入完整的文章页面 功能代码: jQuery(document).ready(function () { //transitions //for more transi
jQuery(document).ready(function () {
//transitions
//for more transition, goto http://gsgd.co.uk/sandbox/jquery/easing/
var style = 'easeOutExpo';
//Retrieve the selected item position and width
var default_left = Math.round(jQuery('#lava li.selected').offset().left - jQuery('#lava').offset().left);
var default_width = jQuery('#lava li.selected').width();
//Set the floating bar position and width
jQuery('#box').css({left: default_left});
jQuery('#box .head').css({width: default_width});
//if mouseover the menu item
jQuery('#lava li').hover(function () {
//Get the position and width of the menu item
left = Math.round(jQuery(this).offset().left - jQuery('#lava').offset().left);
width = jQuery(this).width();
jQuery('#debug').html(left);
//Set the floating bar position, width and transition
jQuery('#box').stop(false, true).animate({left: left},{duration:1000, easing: style});
jQuery('#box .head').stop(false, true).animate({width:width},{duration:1000, easing: style});
//if user click on the menu
}).click(function () {
//reset the selected item
jQuery('#lava li').removeClass('selected');
//select the current item
jQuery(this).addClass('selected');
});
//If the mouse leave the menu, reset the floating bar to the selected item
jQuery('#lava').mouseleave(function () {
//Retrieve the selected item position and width
default_left = Math.round(jQuery('#lava li.selected').offset().left - jQuery('#lava').offset().left);
default_width = jQuery('#lava li.selected').width();
//Set the floating bar position, width and transition
jQuery('#box').stop(false, true).animate({left: default_left},{duration:1500, easing: style});
jQuery('#box .head').stop(false, true).animate({width:default_width},{duration:1500, easing: style});
});
}))
li列表的代码
<div id="lava">
<ul>
<!-- To show "selected" on the home page -->
<li<?php
if (is_page('Home'))
{
echo " class=\"selected\"";
}?>>
<a href="<?php bloginfo('url') ?>">Home</a>
</li>
<!-- To show "selected" on the About Us Page -->
<li<?php
if (is_page('about'))
{
echo " class=\"selected\"";
}?>>
<a href="<?php bloginfo('url') ?>/about/">About Us</a>
</li>
<!-- To show "selected" on the Portfolio Page -->
<li<?php
if (is_page('portfolio'))
{
echo " class=\"selected\"";
}?>>
<a href="<?php bloginfo('url') ?>/portfolio/">Portfolio</a>
</li>
<!-- To show "selected" on the Blog Page -->
<li<?php
if (is_home())
{
echo " class=\"selected\"";
}
?>>
<a href="<?php bloginfo('url') ?>/blog/">Blog</a>
</li>
</ul>
<div id="box"><div class="head"></div></div>
>
>
我一直在想如何得到它,但没有成功
<li<?php
if (is_home())
{
echo " class=\"selected\"";
}
else if(is_page('<?php the_title(); ?>/%postname%/')){
echo " class=\"selected\"";
}
?>>
<a href="<?php bloginfo('url') ?>/blog/">Blog</a>
</li>
>
问题由作者解决:
我必须在li if中使用is_single()
陈述现在一切都好了
如果你回答了一个问题,无论是你自己的还是别人的,请将其作为原始问题的答案发布,而不是编辑问题本身。这将使事情更有条理,让你已经解决问题的其他人更清楚,也将帮助其他人找到他们正在寻找的答案。我现在复制了你的答案,并将其作为社区维基帖子添加到问题中;如果这是实际的正确答案,请接受它。如果它解决了您的问题,请选择这作为正确答案,否则这将永远留在我们的未回答(也称为高优先级)问题列表中。