在加载网站时,wordpress菜单中的自定义链接在多个菜单项中处于活动状态

时间:2015-12-07 06:38:49

标签: wordpress

我有一个菜单如下

<ul>
  <li class="active"><a href="index.html">Home</a></li>
  <li><a href="index.html#section1">About us</a></li>
  <li><a href="index.html#section2">How it works</a></li>
  <li><a href="index.html#section3">Features</a></li>
  <li><a href="index.html#section4">Pricing</a></li>
  <li><a href="Register now.html">Register now</a></li>
  <li><a href="contact.html">Contact us</a></li>
</ul>

第二,第三,第四和第五<li>是第一个<li>中的不同部分,我在wordpress中创建了自定义链接(如http://localhost/adams#section1),首先是wordpress页面。当我添加

add_action( 'init', 'testimonial_postTypes' );
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
 if( in_array('current-menu-item', $classes) ){
         $classes[] = 'active ';
 }
 return $classes;

}

在fuctions.php中

使主页处于活动状态,所有部分也都变为活动状态。我必须改变的地方?我是wordpress的初学者。此外,在主页中滚动不同部分时,我想激活相应的菜单。

我在这里附上wp admin screenshot link on backend

0 个答案:

没有答案
相关问题