-3

I would like to know how to remove the site logo only for a single post in WordPress.

5
  • 1
    Welcome to WP SE. please elaborate more information with your question. what you've done so far etc...
    – Vishwa
    May 9, 2019 at 6:52
  • I was hoping there was a quick css code fix like some other posts ;)
    – Coves84
    May 9, 2019 at 6:57
  • there could be, or not. can't answer without understanding question right?
    – Vishwa
    May 9, 2019 at 6:58
  • Yes, on that post your body tag has class postid-513 so you could write a style for that that hides some or all of the header, e.g. .postid-513 header { display: none; }, or hide div.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
    May 9, 2019 at 7:24
  • Thank you that worked fine for me. .postid-513 header { display: none; }
    – Coves84
    May 9, 2019 at 9:28

1 Answer 1

1

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;
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.