Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this questionI would like to know how to remove the site logo only for a single post in WordPress.
Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this questionI would like to know how to remove the site logo only for a single post in WordPress.
Share Improve this question edited May 9, 2019 at 10:31 norman.lol 3,2413 gold badges30 silver badges35 bronze badges asked May 9, 2019 at 6:43 Coves84Coves84 1 5 |1 Answer
Reset to default 1You 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. – Rup Commented May 9, 2019 at 7:24