WordPress.org

Ready to get started?Download WordPress

Forums

Linking a Background Header (14 posts)

  1. hayesy
    Member
    Posted 6 years ago #

    Hi all,
    Thanks in advance for reading this!

    I'm trying to link my header to my homepage, but I know virtually nothing about CSS or PHP.
    I tried this article but I couldn't get it to work with my theme.

    The relevant part of my style sheet is:

    .header {
    	background: url('img/stripes.jpg') no-repeat;
    	border-bottom: 1px solid #EEE;
    	height: 160px;
    	margin-bottom: 24px;
    }
    .header h1 {display:none;
    	color: #222;
    	font: normal 4em sans-serif;
    	margin-top: 40px;
    	text-align: center;
    }

    And I assume the relevant part of my header is:

    <div class="left">
    
    	<div class="header">
    		<h2><span><?php bloginfo('description'); ?></span></h2>
    		<h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
    	</div>

    I've looked in some other threads, but I must admit... I'm stumped.

    If anyone can help, I'd really appreciate it.
    Thanks!

  2. moshu
    Member
    Posted 6 years ago #

  3. hayesy
    Member
    Posted 6 years ago #

    As I said, I've read through quite a few other threads, but my theme seems to have been set up differently. I'll keep trying, but I was hoping someone more adept might be able to give some specific advice.
    Thanks :)

  4. moshu
    Member
    Posted 6 years ago #

    but my theme seems to have been set up differently
    No it's not.
    This describes exactly what you have to do:
    http://codex.wordpress.org/designing_headers#Making_the_Whole_Header_Clickable
    The only difference is in the example there is a header div and you have a header class - but that doesn't change the main idea.

  5. hayesy
    Member
    Posted 6 years ago #

    Using Javascript in the header:
    <div class="header" onclick="location.href='http://www.yoursite.com';" style="cursor: pointer;">

    I've got it clicking!

    But is there a way to do it without javascript?
    I'm using .header h1 {display:none;
    to hide the text.
    Thanks again!

  6. moshu
    Member
    Posted 6 years ago #

    You may try this:

    <a href="<?php bloginfo('url'); ?>">
    	<div class="header">
    		<h2><span><?php bloginfo('description'); ?></span></h2>
    		<h1><?php bloginfo('name'); ?></h1>
    	</div>
    </a>

    Warning: it is not valid xhtml!

  7. hayesy
    Member
    Posted 6 years ago #

    And that goes after the <div class="header"> tag?

    Sorry, this must be frustrating for you. I'm not terribly good at this.

    EDIT: And how bad is it to have invalid xhtml?
    Edit again: Stupid question, it goes before the <div part. Sorry.

    I'll give it a whirl. I'm not sure about the importance of xhtml validity though.

  8. moshu
    Member
    Posted 6 years ago #

    No, you replace your code with the one above.

    And how bad is it to have JS?

  9. hayesy
    Member
    Posted 6 years ago #

    And how bad is it to have JS?
    Good question. I really am in over my head!

    Which is preferable, do you think? Javascript or invalid xhtml?

  10. moshu
    Member
    Posted 6 years ago #

    I don't like invalid code. But it seems you do: your site is not valid even now :)

  11. hayesy
    Member
    Posted 6 years ago #

    Oh really!

    haha oh wow. I've got it working with that html. But as you say, java or invalid code.

    What does invalid code do?

  12. moshu
    Member
    Posted 6 years ago #

    It can drive crazy certain browsers... if the errors are related to important parts of the site.
    Most people don't care.

    Good reading: http://www.maxdesign.com.au/presentation/benefits/index.htm

  13. moshu
    Member
    Posted 6 years ago #

    Actually, it is not working. Don't you think you should replace "yoursite.com" with your own domain address???

  14. hayesy
    Member
    Posted 6 years ago #

    I was in the middle of reverting back to the JS when my browser went AWOL (Apparently there IS a limit to the number of tabs you can have open before it will hang)

    Thanks, I'll fix that and read that.

    Thank you so much! I really appreciate your help!

Topic Closed

This topic has been closed to new replies.

About this Topic