How to hide menu only on Home page wordpress

一笑奈何 提交于 2020-01-15 13:34:06

问题


I m using a one page theme. I would like to disable or choose not to show the menu on the home page. But when user scrolls down to the next page the menu should become fixed. I have removed the menu from the home page now, however i'm not able to get the menu to be fixed on top for the other pages.

Please advice.


回答1:


You can also go the CSS way.

WordPress adds a class home to the body attribute in home page. You can target that particular attribute to hide the menu as shown below.

.home .menu-class-name{
    display:none;
}

This will hide the menu from home page but will show it on other pages

Note - replace .menu-class-name with your own menu class




回答2:


you can do it some thing like the below code:

<?php
if(is_front_page())
{

//Just comment out the menu section
}
else
{
//write your code to show the menu section
}
?>


来源:https://stackoverflow.com/questions/21524782/how-to-hide-menu-only-on-home-page-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!