conditional logic in the header.php

So I am using WordPress and I have to have a specific logo on a specific page. From research I have to use conditional logic to swap the existing logo with another depending on the current page. Everything I have tried seems to just break the theme.. Any help on guiding me in the correct direction? So basically every page except page_id=79 would have the same logo in the header.

<a id="logo" href="<?php echo home_url();  ?>">

<?php
if(!empty($options['use-logo'])) {
    $default_logo_id = (!empty($options['retina-logo'])) ? 'id="default-logo"' : null;          
    echo '<img '.$default_logo_id.' alt="'. get_bloginfo('name') .'" src="' . $options['logo'] . '" />';         
    if(!empty($options['retina-logo'])) echo '<img id="retina-logo" alt="'. get_bloginfo('name') .'" src="' . $options['retina-logo'] . '" />';
    } else { echo get_bloginfo('name'); }
?>
</a>

Related posts

Leave a Reply

2 comments

  1.     <?php if ( is_page(79) ) { ?>
    
            What to displayed on page 79.
    
        <?php } else { ?>
    
            What will be displayed everywhere else. 
    
        <?php } ?>
    

    This should work.

  2. Try using get_queried_object_id();

    <a id="logo" href="<?php echo home_url();  ?>">
    
    <?php
    if(!empty($options['use-logo']) && get_queried_object_id() != 79) {
        $default_logo_id = (!empty($options['retina-logo'])) ? 'id="default-logo"' : null;          
        echo '<img '.$default_logo_id.' alt="'. get_bloginfo('name') .'" src="' . $options['logo'] . '" />';         
        if(!empty($options['retina-logo'])) echo '<img id="retina-logo" alt="'. get_bloginfo('name') .'" src="' . $options['retina-logo'] . '" />';
        } else { echo get_bloginfo('name'); }
    ?>
    </a>
    

    The url of your logo image is contained within $options['logo']. You should be able to modify this in the admin section of your WordPress installation (try looking in “Appearance -> Header”).