I would like to know how to remove the site logo only for a single post in WordPress.
1 Answer
You can surround your logo part with IF
and check if current post is not that one that should not have the logo.
It looks like you're talking about a custom post type, so you should use is_single()
conditional tag with the ID or SLUG of no-logo-post as a parameter.
if ( ! is_single(513) ) // or slug: is_single('your_post_slug')
{
// display logo here
}
You can also use a custom action hook in the header to display the logo, and place the HTML code of the logo in the function. The header file will remain clean if you have more exceptions, additionally, the use of filter will allow e.g. plugins to change the visibility of the logo. It would look something like this:
header.php
<!-- here logo will be displayed -->
<?php do_action( 'se337467_header_logo' ); ?>
functions.php
add_action( 'se337467_header_logo', 'se337467_display_logo' );
function se337467_display_logo()
{
$show_logo = true;
if ( ! is_single(513) )
$show_logo = false;
//
// allow to override visibility
$show_logo = apply_filter( 'se337467_show_logo', $show_logo);
if ( $show_logo !== TRUE )
return;
?>
<!-- HTML with logo -->
<?php
}
//
// change visibility through the filter
add_filter( 'se337467_show_logo', 'my_other_function' );
function my_other_function( $show_logo )
{
// you can show or hide logo
return $show_logo;
}
.postid-513 header { display: none; }
, or hidediv.branding-wrapper
, or something else. However I'd probably modify my template's header.php to not emit the logo based on some property of the post that you can then set, e.g. a flag in postmeta.