HIDE Nav Menu on a Page Template???


Author Message
FLGuy

Posted: 5/12/2010
Quote message 

Just a quick question that I know you guys can easily answer. How do I HIDE the nav menu on a single page?

I have created several different page templates and just want to hide or remove the NAV menu on my landing page only?

I truly appreciate all the help you can give me.....
 
Adeptris

Posted: 5/13/2010
Quote message 

Try this untested code for header.php file:

Find:

<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>


Change to:

<ul class="art-menu">
<?php if(!is_front_page()) art_menu_items(); ?>
</ul>


What it does,:
in php the not operator is the ! symbol, there is a WordPress function called 'is_front_page which returns a true of false and the art_menu_items returns the menu.

So this example says, if not the front page then load the menu.

Alternative is not to load the menu block at all:
UNTESTED!

<!-- Start hide menu on front page -->
<?php if(!is_front_page()) : ?>

<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>
</div>
<?php endif; ?>
<!-- End hide menu on front page -->



End of lesson :-D

David
 
FLGuy

Posted: 5/13/2010
Quote message 

Quote Adeptris:

Try this untested code for header.php file:

Find:

<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>


Change to:

<ul class="art-menu">
<?php if(!is_front_page()) art_menu_items(); ?>
</ul>


What it does,:
in php the not operator is the ! symbol, there is a WordPress function called 'is_front_page which returns a true of false and the art_menu_items returns the menu.

So this example says, if not the front page then load the menu.

Alternative is not to load the menu block at all:
UNTESTED!

<!-- Start hide menu on front page -->
<?php if(!is_front_page()) : ?>

<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>
</div>
<?php endif; ?>
<!-- End hide menu on front page -->



End of lesson :-D

David


YOU ARE THE MAN!! Thank you....Thank you....Thank You..... I have been pulling my hair out trying to figure it out!
 
Britt

Posted: 10/30/2011
Quote message 

Do I use the same variation of this code to exclude or hide certain navigation menu items when I'm in my product line or shopping cart? Would love to hide the menu all together while in the cart but only have the product line show while viewing the products. These products are posted as pages.

Thanks :)
 
Abland

Posted: 10/30/2011
Quote message 

Hi, Britt,

In the WP admin > Appearance > Menus in the top right there's a dropdown for "Screen Options". Click, then select "CSS Classes" under "Show advanced menu properties".

Select a menu link and when you open it at the dropdown arrow you'll see the option. "CSS Classes (optional)".
Add a class: link-no-show

I'm not sure what ecommerce you're using, but I'll assume a parent page, with item and checkout pages as children. I'll assume for demonstration the following page id's:

Parent page: 22
Item page: 23
Checkout page: 24

In your theme's "header.php" just before the closing </head> tag add the following:
<?php if (is_page(array(22,23,24))) { ?>

<style type="text/css">li a.link-no-show { display: none; }</style>
<?php } else { } ?>

If you're using posts for your ecommerce you would change the conditional to what you'd need. Here's the reference:

http://codex.wordpress.org/Conditional_Tags
 
Britt

Posted: 10/30/2011
Quote message 

Hey Abland

I get what your saying, but I can't seem to override by custom menu. I've always had an issue with this. I have my menu items listed in the area of > Appearance > Menus, but it doesn't appear like I want it to. In the Theme settings, I first had pages, then categories, but again I've never been able to create a custom menu. The main reason why I have pages enabled is because it doesn't delete my home button even if I have a check-mark in the theme settings to show the home link when categories is selected.

I guess I need to figure out how to make my custom menu to work first before I can move to the next step of what I need accomplishes.

Thank You Kindly Abland :)
 
Britt

Posted: 10/30/2011
Quote message 

Oh Heck! I had to choose my Theme Location! Duky Duur!

No moving on to your code hacking! Yee Haw!!!
 
Britt

Posted: 10/30/2011
Quote message 

Quote Abland:

Hi, Britt,

In the WP admin > Appearance > Menus in the top right there's a dropdown for "Screen Options". Click, then select "CSS Classes" under "Show advanced menu properties".

Select a menu link and when you open it at the dropdown arrow you'll see the option. "CSS Classes (optional)".
Add a class: link-no-show

I'm not sure what ecommerce you're using, but I'll assume a parent page, with item and checkout pages as children. I'll assume for demonstration the following page id's:

Parent page: 22
Item page: 23
Checkout page: 24

In your theme's "header.php" just before the closing </head> tag add the following:
<?php if (is_page(array(22,23,24))) { ?>

<style type="text/css">li a.link-no-show { display: none; }</style>
<?php } else { } ?>

If you're using posts for your ecommerce you would change the conditional to what you'd need. Here's the reference:

http://codex.wordpress.org/Conditional_Tags



Hey Abland

I've tried this and its not working yet. Let me give you what I've done:

First of all, I'm using Cart66 Pro and I'm using Pages to publish it all. The cart is using shortcodes that is only a part of the add to cart button. These pages are not part of the cart yet, as the cart pages are not shown on the menu such as the cart and checkout.

Im adding the link-no-show to the page menu item I do not want showing in the CSS Classes (optional) placement.

Just above the </head> tag in the header.php file I copy/paste the code as follows with just starting with one page and one child to test first, then I'll add the remaining children along with the cart and checkout.

Quote :
<?php if (is_page(array(237,88))) { ?> <style type="text/css"> li a.link-no-show { display: none; }</style> <?php } else { } ?>


Page 237 is the parent and 88 is the child. 237 is where all the products are listed on one page and 88 is one product. The top navigational menu does work with the drop-down feature with the parent on top and children below.

I have also tried this in multiple ways such as adding the link-no-show to the product page and adding the other id# to the php code. I've mixed this around in as many ways as possible from what I think.? Ive also tried just adding the one parent page of 237 to the php code and the link-no-show to one menu item I do not want showing in the CSS placement.

Thank You Kindly for Your Support! :)
 
Abland

Posted: 10/31/2011
Quote message 

Hi, Britt,

I'm not very familiar with Cart66, but since it is using pages are you able to apply a page template? If so, copy the contents from "page.php" into a new file: "page-cart.php".
( I'm assuming that currently you use the default template.)

At the very top of that new file add the following before all other code:
<?php

/*
Template Name: Cart66
*/
?>

That will give you the page template option, "Cart66", so apply it to your product pages. Then change the conditional from is_page to is_page_template:
<?php if (is_page_template('page-cart.php') ) { ?> 

<style type="text/css">li a.link-no-show { display: none; }</style>
<?php } else { } ?>

I don't have an install of that cart to test, so post back with your results.
 
RGerhart

Posted: 11/6/2011
Quote message 

Quote Adeptris:

Try this untested code for header.php file:

Find:

<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>


Change to:

<ul class="art-menu">
<?php if(!is_front_page()) art_menu_items(); ?>
</ul>


What it does,:
in php the not operator is the ! symbol, there is a WordPress function called 'is_front_page which returns a true of false and the art_menu_items returns the menu.

So this example says, if not the front page then load the menu.

Alternative is not to load the menu block at all:
UNTESTED!

<!-- Start hide menu on front page -->
<?php if(!is_front_page()) : ?>

<div class="art-nav">
<div class="l"></div>
<div class="r"></div>
<ul class="art-menu">
<?php art_menu_items(); ?>
</ul>
</div>
<?php endif; ?>
<!-- End hide menu on front page -->



End of lesson :-D

David


Hello David,

Thank you for your code examples.
I tried them out, but could not get them to work for my Artisteer template.
In the header.php I do not find the mentioned code of the first option.

When I try to completely erase the menu for certain pages, what I would like to do, the function art_menu_items(); gives back an error and though the code works to select the pages, the selected pages do not build correctly.
They give back an error, that the function was not found:
Quote :
Fatal error: Call to undefined function art_menu_items() in /.../header.php on line 26


As I did not find the function either, I tried to adjust the function, but am not sure where to look for the correct function to enter here in my case.

<!--Start hide menu on US pages -->

<?php if (is_page(array(176))) : ?>

<div class="art-nav">

<div class="1"</div>

<div class="r"></div>

<ul class="art-menu">

<?php art_menu_items(); ?>

</ul>

</div>

<?php endif; ?>

<!-- End hide menu on US pages -->


I do not use a custom menu, so the selection option suggested by Abland did not work either.

Thank you for your kind help!
 
Britt

Posted: 11/19/2011
Quote message 

Quote Abland:

Hi, Britt,

I'm not very familiar with Cart66, but since it is using pages are you able to apply a page template? If so, copy the contents from "page.php" into a new file: "page-cart.php".
( I'm assuming that currently you use the default template.)

At the very top of that new file add the following before all other code:
<?php

/*
Template Name: Cart66
*/
?>

That will give you the page template option, "Cart66", so apply it to your product pages. Then change the conditional from is_page to is_page_template:
<?php if (is_page_template('page-cart.php') ) { ?> 

<style type="text/css">li a.link-no-show { display: none; }</style>
<?php } else { } ?>

I don't have an install of that cart to test, so post back with your results.


Hey Abland!

Ok, so I have done a File Save As on the page.php file and named it page-cart.php. Now I'm confused on what to do with your code. Do I add this code and replace it in the page-cart.php? When I add your code below the line of:

<?php if(have_posts()) {

/* Start the Loop */
while (have_posts()) { the_post(); get_template_part('content', 'page');


get a syntax error of:

unexpected '<' in /home2/themass4/public_html/wp-content/themes/mCouponsNoMeta77/page-cart.php on line 14

line 14 is the <?php if (is_page_template('page-cart.php') ) { ?>

When I take out the lines of:

<?php if(have_posts()) {
/* Start the Loop */
while (have_posts()) { the_post(); get_template_part('content', 'page');


I then have to take out the comments code of:

/* Display comments */
if ( theme_get_option('theme_allow_comments')) { comments_template(); } } } else { theme_404_content(); } ?>


Then I get a blank page w/ no data in the content area. The sidebar menu and the top navigation is working.

I did create a new page w/ the new template named shopping, (changed from your cart66 name), and the shopping cart widget works but my plain text w/no shortcodes is not appearing in the content area.

Thank you kindly Abland for your support! It took me a while to return to this part as I've been creating/customizing the members area.

:)

 
Britt

Posted: 11/19/2011
Quote message 

Hey Abland!

I just added the code of

<style type="text/css">li a.link-no-show { display: none; }</style>

considering the content is showing now, in the menus im adding the code of

link-no-show in the CSS Classes (optional) field. and the menu is still showing.

 
Britt

Posted: 11/19/2011
Quote message 

Considering I'm using a custom theme, can't I just go to the menus now and customize this navigation menu w/ the theme?
 
Britt

Posted: 11/19/2011
Quote message 

Quote Abland:


I don't have a is_page is my page.php. Ive actually gone to a save as from the onecolumn-page.php.



 
Abland

Posted: 11/20/2011
Quote message 

Hi, Britt,

I'm not sure why it's not working. I tested an install of Cart66 Lite, not pro but I figured they are similar, and it worked fine with just using the the is_page(array

Change your cart pages back to the default page template, then try it this way just before the closing </head> in header.php: (single quotes around each page id)
<?php if (is_page(array('237','88'))) { ?> <style type="text/css"> li a.link-no-show { display: none; }</style> <?php } else { } ?>

Ensure that you add the link-no-show class to your menu link.
 
Britt

Posted: 11/20/2011
Quote message 

Quote Abland:


I don't know either? I have everything according. :-@

I hate when it takes me dayz to figure out a 5minute fix!



 
Britt

Posted: 11/20/2011
Quote message 

When I click Ctrl U, I can see the code of


<style type="text/css">li a.link-no-show { display: none; }</style>

and I can see the link-no-show in all the parent and child menu items.

I'm in the /store/cart page id# 78

also in the store/checkout page id# 79

Using the default page theme on both.

This is how my code looks in the header.php file:

<?php if (is_page(array('78','79'))) { ?> <style type="text/css"> li a.link-no-show { display: none; }</style> <?php } else { } ?>
</head>

 
Britt

Posted: 11/20/2011
Quote message 

This is what I need and can't even find it. I guess it's custom for their use only.

http://www.youtube.com/watch?v=nyaY_3yoOX8
 
Britt

Posted: 11/20/2011
Quote message 

How do I get an option while editing my page to choose which custom menu to show? There is already a Theme Options & Page Attributes to add this simple drop down menu to show your custom menu and to hide it all together.
 
Britt

Posted: 11/20/2011
Quote message 

Looks like the child menu items are not showing but the parent is
 
Abland

Posted: 11/21/2011
Quote message 

Hi, Britt,

Are the parent pages included in the page id"s array?

You might also find this post useful:
http://www.artisteer.com/?post_id=179583&p=forum_post&topicsPage=2&forum_id=13