dongliang1865 2014-05-28 01:58
浏览 152
已采纳

如何将活动的css类添加到Wordpress中的链接

how to add active css class to a link in Wordpress such that the active menu li will have different color when that link is viewed.

<ul>
  <li class=""><a href="/news">News</a></li> 
  <li class="devider">&nbsp;</li>
  <li class=""><a href="/about">About Us</a></li> 
  <li class="devider">&nbsp;</li>
  <li><a href="#">Partners</a></li> 
  <li class="devider">&nbsp;</li> 
  <li><a href="/vacancy">Careers</a></li>  <li class="devider">&nbsp;</li>
  <li><a target="_blank" href="/webmail">Email Login</a></li>
</ul>
  • 写回答

2条回答 默认 最新

  • dongyou5271 2014-05-30 17:45
    关注

    This is the most simple way to solve it. No javascript or anything than just Wordpress

    Use it just using Wordpress built-in boolean function

     <li<?php if (is_page('services')) { echo ' class="current_page_item"'; } ?>><a href="<?php echo home_url();?>/services">Services</a></li>
    

    here is the link from where i got this idea. http://www.vanseodesign.com/wordpress/hightlight-current-page-wordpress/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料