How to hide menu only on Home page wordpress - wordpress

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.

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

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
}
?>

Related

Wordpress main menu item appears out of nowhere for mobile version

I've been asked to look at the main menu on luxmux.com,
This is a Wordpress website, it has full and mobile version and the menu is different for both. For full version the menu works well and shows all the items as per Wordpress Dashboard>>Appearance>>Menu.
For the mobile version however the menu adds a "- MENU -" item to the menu (to the very top). I've been asked to remove this item.
From what I see the menu is generated in header.php with this single line -
<?php wp_nav_menu( array( 'menu_id'=>'nav', 'theme_location'=>'main-navigation')); ?>
Initially I thought that I can remove a single item by using exclude, as per this example -
wp_nav_menu exclude pages from menu
However, the "- MENU -" item does not have a page ID.
Thanks.
The reason that's happening is that Javascript is building the menu based on the main menu. Look at the selectnav.js file:
view-source:http://www.luxmux.com/wp-content/themes/shootingstar/js/selectnav.js?ver=0.1
Look into that file and you can see label = o.label || "- MENU -",
You'll have to know some JS to fix this issue.
Find the css identifier for the element (like a class or id) and just add the following css to any css file loaded by the admin section:
.whatever-class {
display: none !important;
}

How to stop showing menu in static home page wordpress

Ok, I'm creating a wordpress theme. I don't want my navigation menu to show in the home page "Only" if the site admin setup Front page displays > A static page (select below).
otherwise I want to show the menu in home page & other pages too. I've used this <?php if(!is_front_page()):?> function, but it is not working.
some one suggest me <?php if(!is_home()):?>, but it is not working either.
So how do I make it work?
Please follow the below steps:
Dashborad > Settings > Reading
Select A static page (select below) option in Front page displays section.
Select the page you want to display from Front Page drop down box.
In header.php in the code for displaying menu, make the alteration as below.
if ( ! is_page( '{slug of the selected page in Front Page drop down box}' ) ) {
//enter your code to display menu here
}
?>

Custom set "current-menu-item" class for specific pages in WP

I'm creating a custom WP theme and I'm using the Wordpress navigation bar. When switching between different pages, WP adds a "current-menu-item" class to link in navigation bar which corresponds to the current page.
However, if that page/post is not present in the nav bar, it doesn't add the "current-menu-item" to any of the nav bar items.
My problem is, when a user visits the page "BLOG" (which is actually a category page) and clicks on a certain post which opens the single.php template, I want the nav bar item "BLOG" to be underlined as it would if the visitor was visiting a blog page.
Sometimes I will want another nav bar item to be underlined when landing on SINGLE, depending on where the user came from (I also have homepage posts, then I'd like HOME to be underlined)
How do I accomplish this? Thanks.
You can use a filter and check what page you are currently on using conditional statements and add classes before the menu gets displayed:
function add_custom_classes($classes, $item){
if(is_single() && $item->title == 'BLOG'){
$classes[] = 'current-menu-item';
}
return $classes;
}
add_filter('nav_menu_css_class' , 'add_custom_classes' , 10 , 2);

WordPress Twenty Thirteen Theme: How to hide ".entry-content" only on main page

I would like to hide the body text below the headlines on my blog's main page, the page where all articels are listed, but would like keep it on the single post page.
My first thought was to set .entry-content to display:none but this made it disappear on both pages.
Does anyone have an idea how to remove it only on the front page?
Wordpress assigns a unique class to the body for each page. you can see the body classes by viewing source. Home page is given the class .home so you could target entry-content this way:
.home .entry-content{ display:none; }
alternatively you can create a custom template for your home page and just remove the html.
http://codex.wordpress.org/Page_Templates

WP nav menu bug

I have used WP nav menu in my website. It works fine. I have added the sub link under the home link. But it is not properly displayed. Please refer the screenshot.
In the above image, "support our work" sub link is fine. But the Home sub link is not properly displayed. I need "News, Calendar, Like Us On FaceB" displays under the HOME link similar to "Support our work". Home Page does not accept the sub links.
When you have a static page as home page it is possible.
Go to Settings, Reading, Front page displays. Then select your "Front page", that will appear in the menu as the home link.
Then in functions.php of your theme add this code:
function my_page_menu_args( $args ) {
$args['show_home'] = false; // Do not show 'home' link in the menu.
return $args;
}
add_filter('wp_page_menu_args', 'my_page_menu_args', 1000);
In the menu, the subpages of the selected page, will now appear as submenu items.
Try to add theme_location => 'secondary'

Resources