radionowhere
radionowhere

Reputation: 121

Wordpress Site - Unlink Header Image On Just One Specific Page

I've got a wordpress site, here -

http://www.radionowhere.net/sandbox/

Pretty sure I should be looking at adding some conditional PHP to my site's header.php file (yes, I know I should be using a child theme, but I'm not), but I'm not sure exactly where it should go (drop it right into the middle of the link html?).

Here's what I assume is the relevant portion of the header.php code:

<body <?php body_class(); ?>>
    <div id="page" class="hfeed site">
        <header id="masthead" class="site-header" role="banner">
            <a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
                <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
                <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
            </a>

            <div id="navbar" class="navbar">
                <nav id="site-navigation" class="navigation main-navigation" role="navigation">
                    <h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
                    <a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
                    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
                    <?php get_search_form(); ?>
                </nav><!-- #site-navigation -->
            </div><!-- #navbar -->
        </header><!-- #masthead -->

Thoughts? Thanks!

Okay, not sure this is exactly how to follow up, but...Thanks, Sean. This makes sense to me, but I guess I'm not putting it in the right place? This is what I've got right now, and it's borking my site and giving me a plain white screen:

<div id="page" class="hfeed site">
    <header id="masthead" class="site-header" role="banner">
        <?php if(is_page('2850')) { ?>
            <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        <?php } else { ?>
        <a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
            <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        </a>
        <?php ?>

        <div id="navbar" class="navbar">
            <nav id="site-navigation" class="navigation main-navigation" role="navigation">
                <h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
                <a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
                <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
                <?php get_search_form(); ?>
            </nav><!-- #site-navigation -->
        </div><!-- #navbar -->
    </header><!-- #masthead -->

Did I screw something up?

Upvotes: 0

Views: 377

Answers (3)

Sean Thompson
Sean Thompson

Reputation: 902

<?php if(is_page('home')) { ?> //or whatever the name of the page is
     <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
     <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
<?php } else { ?>
<a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
       <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
        <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
 </a>
<?php } ?>

Upvotes: 0

Jeffrey Carandang
Jeffrey Carandang

Reputation: 408

I think since you are not sure where to add the function code you can use jquery instead :

jQuery('.page-id-6 a.home-link').on('click', function(e){
e.preventDefault(); return false;
});

Then add this to your css :

.page-id-6 a.home-link:hover{ cursor:default; }

Let me know if this works fine

Upvotes: 0

Gonz
Gonz

Reputation: 1219

You could use the function is_page($id). Take a look

Update

Taking a look at your code, you forgot a }:

<div id="page" class="hfeed site">
    <header id="masthead" class="site-header" role="banner">
        <?php if(is_page('2850')) { ?>
            <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        <?php } else { ?>
        <a class="home-link" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
            <h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
            <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
        </a>
        <?php } // you forgot this?>

        <div id="navbar" class="navbar">
            <nav id="site-navigation" class="navigation main-navigation" role="navigation">
                <h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
                <a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
                <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
                <?php get_search_form(); ?>
            </nav><!-- #site-navigation -->
        </div><!-- #navbar -->
    </header><!-- #masthead -->

Upvotes: 1

Related Questions