Hide menu on one page

By: Alan Kindree | Asked: 05/19/2023
ForumsCategory: General questionsHide menu on one page
Alan KindreeAlan Kindree asked 11 months 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 11 months ago

Which menu? There are many

Alan KindreeAlan Kindree replied 11 months ago

on one page piratedivebar.com/dog the top menu

1 Answers
Alan KindreeAlan Kindree answered 11 months 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 11 months 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 11 months ago

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

Victor Font replied 11 months 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