Hide menu on one page

By: Alan Kindree | Asked: 05/19/2023
ForumsCategory: General questionsHide menu on one page
Alan KindreeAlan Kindree asked 1 year ago

Hi All Is there a plugin that will hide the menu on just one page? I am using the twenty nineteen theme.  Thanks Alan

Victor Font replied 1 year ago

Which menu? There are many

Alan KindreeAlan Kindree replied 1 year ago

on one page piratedivebar.com/dog the top menu

1 Answers
Alan KindreeAlan Kindree answered 1 year ago
.page-id-17832 #top-menu-nav {     display: none; } I tried to add this using the code snippets plugin, but something seems to be wrong
Victor Font replied 1 year ago

You have a couple of things going on.

First, you are targeting a non-existent element id. There is no element with an id called #top-menu-nav on that page. The menu id is #site-navigation.

Second, I would use a PHP script to inject the CSS on the page rather than loading it on every page.

This is how I would write the script:

if ( is_page( '17832' ) {
add_action('wp_head', 'hide_top_navigation');
}

function hide_top_navigation() {
echo PHP_EOL . "<style>
#site-navigation { display: none;};
</style>" . PHP_EOL;
}

Alan KindreeAlan Kindree replied 1 year ago

Thanks. I am going to paste that into the plugin called code snippets

Victor Font replied 1 year ago

I didn't test the code. It may need some tweaking. Let me know if it works.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right