hide the header on a page

WordPress AI Code Robot

Create WordPress code snippets for free without a developer!

{Name (First):7.3} requested the  following code from my WordPress AI Code Generator.

hide the header on a page

The robot generated the following code:

WordPress does not provide built-in functionality to hide the header for specific pages, so we'll need to create a custom function to accomplish this. I'll show you how to hide the header on a specific page by using its page ID.

Here is the code snippet you can use:

“`php
function nm_hide_header() {
if ( is_page( 'your page id here' ) ) {
?>
<style type="text/css">
.site-header {
display: none;
}
</style>
<?php
}
}
add_action( 'wp_head', 'nm_hide_header' );
“`

In the above code, replace `'your page id here'` with the actual ID of the page you want to hide the header on. This will add a CSS rule to the `<head>` section of the page to hide the .site-header element.

Please note that this code assumes that your theme uses the ".site-header" class for the header. You will need to adjust the CSS selector if your theme uses a different class for the header.

More
CODE SNIPPETS