Jump to content
Sign in to follow this  
elyons3683

Adding subnav only on specific pages

Recommended Posts

elyons3683    0
elyons3683

I have enabled the Drop Down menus for the nav bar, but on one page, I'd like to have some sub nav available. My site is www.elizabethlyons.com. For example, if you rollover Books in the nav bar, 3 choices are available. If you click on You Cannot Be Serious, I'd like there to be 4 new links on which the user can click at the top of the You Cannot Be Serious page. These links would only be accessible via this page. How could I do this? Thank you!

Share this post


Link to post
Share on other sites
Andrew    201
Andrew

have you looked around for plugins? by subnav you mean the one underneath the header? to get that right you might have to add a couple custom functions to the subnav code,

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

I have not been able to find a plug-in that will accomplish this only on certain pages. I think Jeff was looking into how I could modify the code, and it may very well be that I need to add some custom functions to the subnav code. I just need some direction on how to do it!

Share this post


Link to post
Share on other sites
jnoh    0
jnoh

hey elyons :) this is jeff. So what we'll want to do is add a condition to the subnav code:

<?php [b]if(is_page('[page-slug-for-book1]') || is_page('[page-slug-for-book2]') || is_page('[page-slug-for-book3]'))[/b] require(LIB.'/_subnav.php') ?>

Replace [page-slug-for-book1] with the appropriate page-slug. Same goes for the other two books. Let me know if that makes sense.

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

Hi Jeff! This does make sense. We'll see how much when I go to put it into action! Does it matter where in the subnav.php code I put your modifications? At the top of the code, the following code appears: ` <?php if(($post->post_parent || wp_list_pages("title_li=&child_of=".$post->ID."&echo=0")) && !$bbpress_forum && !is_search() ):?>

` Do I want to place this new code BETWEEN the `):?>` and the `
` code?

Share this post


Link to post
Share on other sites
Andrew    201
Andrew

I believe you would add it to the beginning of the if statement: `if (is_page('[page-slug-for-book1]') || ($post->post_parent || wp_list_pages....`

Share this post


Link to post
Share on other sites
jnoh    0
jnoh

elyons, i should have been more clear. my apologies. You'll find `<?php // require(LIB.'/_subnav.php') ?>` in the header.php file. Replace that line with: `<?php if(is_page('[page-slug-for-book1]') || is_page('[page-slug-for-book2]') || is_page('[page-slug-for-book3]')) require(LIB.'/_subnav.php') ?>`

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

Jeff- Okay. So far so good! The new sub nav page is working as a separate drop down menu off the first. I'd also like it so that when you go to the You Cannot Be Serious subpage (off Books) you see the names of the subnav pages across the top of the page. So, if someone is in the You Cannot Be Serious page, they see across the top the various other pages they can go to from that page only (the first would be the Treat of the Moment). Does that make sense? How do I do that? 47dLf.png

Share this post


Link to post
Share on other sites
jnoh    0
jnoh

Hm. Is this the code you entered? `<?php if(is_page('you-cannot-be-serious') || is_page('there-we-go') || is_page('here-we-come')) require(LIB.'/_subnav.php') ?>` Also on a sidenote, I noticed on your feature page, you're not using the feature boxes. To hide the feature boxes underneath the main feature box slider, add this code to the Custom Code > CSS Rules field: `#container .fboxes {display:none}`

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

Perfect - I removed the feature boxes. Thanks for catching that! Yes - the code you entered above is the code I entered. Is it correct? Liz

Share this post


Link to post
Share on other sites
jnoh    0
jnoh

Liz, sorry there were some typos in my code above. I fixed those errors in the post and entered it again below! Try this one last time, and let me know if it works. `<?php if(is_page('you-cannot-be-serious') || is_page('there-we-go') || is_page('here-we-come')) require(LIB.'/_subnav.php') ?>`

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

Hi Jeff - That allowed the regular subnav to be there on the You Cannot Be Serious page (which is a sub page of Books) but it didn't allow the subnav pages of You Cannot Be Serious to be shown (see image attached). When I go to the individual subnav pages of Books, the other pages show up on the right hand sidebar (see 2nd attachment), but from the main You Cannot Be Serious page, other than seeing it in the drop-down box, the user has no way to know that there are the Treat of the Moment, Inspiration, etc. page. Q0orZ.png8FVry.png

Share this post


Link to post
Share on other sites
elyons3683    0
elyons3683

That 2nd screen shot wasn't great. Here's another one. This is what you get in the sidebar when you are ON the subnav pages of the You Cannot Be Serious page. But when you're on the main You Cannot Be Serious page, you only see the Books subnav menu, not the You Cannot Be Serious subnav menu. Is this the biggest mess you've ever seen? GTbIe.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×