Hyperlinking within php?

Discussion in 'Web Design and Development' started by Kingsly, Mar 21, 2013.

  1. macrumors 68040


    Personally, I've given up on wordpress - I can bs my way through a pretty nice looking website with html and css in DW, but all this php business has my head spinning... :eek:

    My wife's site has a header banner and for whatever reason this particular theme does not allow for the provision to make that header banner image a clickable "back to home" link. I've given it my all, and only managed to break the site over and over. Thank goodness for backups!

    This is where I [think] i've narrowed the code relating to the image to be, in the header.php file:

    <?php do_action( 'instamate_before_header' ); ?>
    	<?php $header_image = get_header_image();?>
    	<header id="branding" class="clearfix" role="banner"<?php if ( ! empty( $header_image ) ) { ?> style="background: url(http://www.starobryan.com/wp-content/uploads/2012/12/logo2.jpg) no-repeat top center;max-width: <?php echo get_custom_header()->width; ?>px; min-height: <?php echo get_custom_header()->height; ?>px;"<?php } ?>>
  2. macrumors 6502

    Apr 3, 2006
    Beacon, NY
    The way that header is being handled it makes it almost impossible to link it. The header image is a css background image. The site title is a clickable link as a should be in a Wordpress site, but is hidden with css.

    I see a few ways it could be done.

    • Instead of having the image as a background of the header area, put the site title back in and put the image as a background on that.
    • Put the site title back in, position it over the image and use a negative indent to hide the text.
    • In the template put the image directly in the link replacing the text.
  3. macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    A cheap fix (noting the advice of jsm4182 is for far better long term solutions):

    As your site uses jQuery:

    $("header#branding").click(function () {
    Or if you prefer traditional JS:

    function goHome() {
    Basically I'm adding an event listener for an onClick for your header tag and redirects to "/" which is your home page (docroot, relative path). This is a cheap fix as there is an obvious dependency on JS/jQuery.

    Add either into the theme's script.js where appropriate.

Share This Page