Support » Fixing WordPress » hyperlink branding page area to a specific post or page

  • Resolved Mark Shirley

    (@ravalde)


    Hi – how can i hyperlink the branding image area to a specific page not the home page of the site I think this is the code below in the header file that does this but I could be wrong.

    <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
Viewing 13 replies - 1 through 13 (of 13 total)
  • esmi

    (@esmi)

    Forum Moderator

    What theme are you using?

    Hi esmi

    twenty-eleven child theme we are using the home page with no menu and need the internal pages to link to a specific page other than the home page.

    esmi

    (@esmi)

    Forum Moderator

    Well, you’re on the right track. In your child theme’s header.php template file, you could use something like:

    <?php if( is_front_page() || is_home() ) $banner_url = esc_url( home_url( '/' ) );
    else $banner_url = 'http://example.com/';?>
    <a href="<?php echo $banner_url; ?>">

    Then replace http://example.com/ to your chosen url. Is this new linked page one of your WP site or is it for an external site?

    Well done esmi – that works fine – top man – Thanks bundles 🙂

    or woman Ha Aa

    PS – just seen the last bit of your answer it was an internal page – cheers

    esmi

    (@esmi)

    Forum Moderator

    If it’s an internal page, the best approach (as opposed to hard coding the url) would be to make a note of that page’s ID and then use get_permalink( $id );. That would make the link usable even if you changed your permalink structure.

    Wow thanks esmi – no idea how to code that one im a cut and paste php guy – the code you gave me seems to work fine for an external page.

    sorry ment to say internal on post above

    Do you mean something like this esmi

    <?php if( is_front_page() || is_home() ) $banner_url = esc_url( home_url( '/' ) );
    else $banner_url = 'http://example.com/';?>
    <a href="<?php echo get_permalink( 268 ); ?>

    Ha – just used this code below for the page id seems to work

    <a href="<?php echo get_permalink( 265 ); ?>">
    esmi

    (@esmi)

    Forum Moderator

    Yep – that’s exactly what I meant. Permalink-structure-change proofed!. 🙂

    Thanks again got both ways now 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘hyperlink branding page area to a specific post or page’ is closed to new replies.