Archived

This topic is now archived and is closed to further replies.

  • 0

Adding subnav only on specific pages

Question

Posted · Report post

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

13 answers to this question

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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

Posted · Report post

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