Wordpress 主菜单 - 仅在主页上隐藏“主页"链接 [英] Wordpress Main Menu - Hide 'Home' link on homepage only

查看:44
本文介绍了Wordpress 主菜单 - 仅在主页上隐藏“主页"链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在主页上隐藏从 Wordpress 主菜单生成的主页"链接,并在网站的其余部分显示它.

I need to hide the "Home" link that's generated from Wordpress main menu on the homepage, and show it on the rest of the site.

我尝试创建自己的没有主页"链接的菜单,并在 header.php 文件中手动添加主页"链接,但它位于菜单的末尾,看起来不是一个很好的解决方案.

I tried creating my own menu with no "Home" link and adding the "Home" link manually on the header.php file but it goes to the end of the menu and does not look like a pretty solution.

有什么想法吗?使用最新的 Wordpress 3.2

Any ideas? Using latest Wordpress 3.2

推荐答案

如果你只想对用户隐藏它,我建议使用下面的CSS:

If you only want to hide it to the users, i suggest using the following CSS:

body.home a[title="Home"] {
    display: none;
}

说明:Wordpress 为 body 标签生成了几个类.home 类用于隐藏主页上标题为 Home 的所有链接.

Explanation: Wordpress generates several classes for the body tag. The home class is used to hide all links with the title Home on the homepage.

工作示例(取自默认主题的代码):http://jsfiddle.net/yJVyK/1/

Working Example (code taken from the default theme): http://jsfiddle.net/yJVyK/1/

注意:属性选择器在 IE6 中不起作用

Note: The attribute selector does not work in IE6

这篇关于Wordpress 主菜单 - 仅在主页上隐藏“主页"链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆