• I am in the process of creating my custom theme, I am using the latest version of the Starkers theme as a starting pont. I want to replace the h1 tag with an image so this is what I did in header.php file:

    [Munged code removed. Please post code or markup snippets between backticks or use the code button.]

    here is the css:
    header h1#logo{
    width: 298px;
    height: 113px;
    text-indent: -9999px;
    background: url(images/logo.jpg)no-repeat;
    }

    [please check the forum guidelines for posting code]

    my problem is that the link tag is not working on the other pages, if I don’t have the background set to the image I get a missing image icon, please help I looked around and tried some of the solutions that I found but can’t seem to get it to work.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter TonyB67

    (@tonyb67)

    So if I don’t use the text-indent and the background url in the css than I get a missing image icon where the h1 should be?

    Have you validated the page for errors?

    Posting a link to your site would be helpful too.

    Thread Starter TonyB67

    (@tonyb67)

    I am doing this locally
    would it help if I ran it live, but you can’t see my php.
    seems like it is not finding the image, shows up fine on the homepage
    (this is a static front page )

    Thread Starter TonyB67

    (@tonyb67)

    Here is the code:

    <body <?php body_class(); ?>>
    <header>
    	<div class='center'>
    	<h1 id='logo'>
    		<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img src='wp-content/themes/halfway-v-2/images/logo.jpg' alt="<?php bloginfo('name'); ?>" /></a>
    	</h1>
    	<h2><?php bloginfo( 'description' ); ?></h2>

    Try actually “reading” your CSS above. You set the background image on the H1 element and then move the entire element off the page using a negative text indent – including anything inside the H1 (like an <a> tag, for example).

    Now do you understand why it’s doing exactly what you told it to do?

    Thread Starter TonyB67

    (@tonyb67)

    I do esmi
    this is the css:

    h1#logo{
      width: 298px;
      height: 113px;
      /*text-indent: -9999px;*/
      /*background: url(images/logo.jpg)no-repeat;*/
    }

    I did that to get the image to show up, if I don’t have a background set , I get a missing image in chrome and the h1 shows up in ff but not the image.??

    You cannot have an image applied to an element, then hide the element and expect the image to show. That’s like putting a photo in a transparent box, hiding the box behind a curtain and still expecting to still see the photo.

    A better way would be to just remove the text – not the H1 element – off the screen.

    <h1 id='logo'><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><span><?php bloginfo('name'); ?>" /></span></a></h1>

    h1#logo{
      width: 298px;
      height: 113px;
      background: url(images/logo.jpg)no-repeat;
    }
    h1#logo span {
      display:inline-block;
      position: absolute;
      top: -9999px;
      left: -9999px;
    }
    Thread Starter TonyB67

    (@tonyb67)

    Yes the image shows up this way but the link doesn’t work still 🙁

    Then you probably have some other CSS that is affecting the link. Try using Firefox with the Firebug add-on for this kind of CSS work.
    http://getfirebug.com/

    Thread Starter TonyB67

    (@tonyb67)

    here is a link to the site
    http://halfwaytoavalon.com/test/

    Thread Starter TonyB67

    (@tonyb67)

    I am new to WordPress not css for some reason it is not finding the image?
    There isn’t much going on as far as the css is concerned, I am using the Starkers theme as a starting point, I think I understand how things are working but this is stopping me from continuing, I hate when I can’t understand something, thanks for your help 🙂

    Thread Starter TonyB67

    (@tonyb67)

    Is there another way to replace the font ? the band really wants to use this font but I can’t use the font in the css file because of the name ‘Jellyka-Estrya’sHandwritingRg’,

    I think the third single quote is the problem, what about cufon ?

    Thread Starter TonyB67

    (@tonyb67)

    can I just delete the php and have an image that points to index.php will that work?

    Where did you get that font? Since it’s not a regular font that is on most people’s computers, you need to use Google web-fonts (or another equivalent) — if you do that, you can simply use that font for the h1 tags — and those are already linked to your home page…

    Thread Starter TonyB67

    (@tonyb67)

    This shouldn’t be that hard to find a solution to, all I want to do is replace an h1 with an image, works on home page but can’t find the image when I load the other pages ?
    and WPyogi if you read my posts you will see that I tried using css to replace the font with a web font, no the font is not hosted on Google font api, I wish it was that easy 🙂

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘Problems with replacing h1 tag’ is closed to new replies.