Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAtulesh Kumar
iOS Development Techdegree Student 2,139 PointsDifferent navigation style from the homepage (front-page) and inner pages
In my website, I am using two different navigation style. The homepage navigation is different than the inner pages. You can take a look at the demo site here: http://atulesh.com/beta. When you click on the About Me page, you will notice a different behavior of the navigation.
Now, i want to put a condition for the navigations to appear as such. When the page is front-page.php (i.e the static homepage) it should load the nav with 'x' class. But when there is other page than the front-page, it should load the nav with 'y' class.
Can someone help me to achieve this through the functions.php. I dont want to do any hardcoding or something that can disturb the website.
Looking for some positive solution on this, since I am not an expert and very new to wordpress with little knowledge of php. I am just trying to build my website by myself.
Help appreciated.
4 Answers
Andrew Rowberry
3,579 Points<?php if(is_front_page){ $args = array( 'menu' => '', 'menu_class' => 'x' ); wp_nav_menu($args); } ?>
Add some logic if its front-page display menu with different class.
Andrew Rowberry
3,579 Pointsoh nvm i didnt see u want it just in your functions.php. i believe you can use the same logic with wp_enqueue_script
Atulesh Kumar
iOS Development Techdegree Student 2,139 PointsThanks Andrew for your reply. However I tested the below solution and found it working, provided by Colin Marshall. Thanks again for your help :)
<?php
if (is_page('home')) {
get_header( 'home' );
} else {
// Code for header for pages that aren't the homepage goes here
}
?>
Colin Marshall
32,861 PointsThat is strange that my answers disappeared! Thanks for the alternate solution Andrew Rowberry!
Andrew Rowberry
3,579 Pointsnice :)
Atulesh Kumar
iOS Development Techdegree Student 2,139 PointsColin Marshall , no your answers are still there, but in different post that I created accidently since I wasn't familiar of the site forum structure. Its in this post