• Resolved codinedawn

    (@codinedawn)


    I’m sure it is common to use relative image paths into your wordpress theme, normally in header.php. I normally put the logo in the images folder of the root directory. the path to the logo is then coded as
    <img src="/images/logo.jpg" />

    This works until you change your permalinks. Permalinks change the url to reflect a directory stucture in place of the ugly ‘?page_id=1’, thus breaking the path to /images.

    The hack:
    Where you have used relative image paths, (as intro code), replace it with <img src="<?php echo get_option('siteurl'); ?>/images/logo.jpg" />

    This uses your specific siteurl as a prefix to the path of the image.

    Hope this helps, it is a great hack

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey, thanks for this it worked perfectly. Would you happen to know how I can link the header image to the main page now?

    I love it ?? Thanks

    My header logo images I hardcoded into header.php kept breaking when I would go into the inner pages. like the archive category pages. I figured it was the permalinks when I looked at the missing images path. This solution worked like a charm for that. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Logo and template img path broken after permalink change’ is closed to new replies.