[resolved] Logo and template img path broken after permalink change (4 posts)

  1. codinedawn
    Posted 7 years ago #

    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

  2. tommy7l
    Posted 7 years ago #

    Hey, thanks for this it worked perfectly. Would you happen to know how I can link the header image to the main page now?

  3. sweetangst
    Posted 7 years ago #

    I love it :) Thanks

  4. principalcrown
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic