Grow your CSS skills. Land your dream job.

[Solved] Hard Code Images in WordPress Pages

  • # November 3, 2009 at 3:29 pm

    I’ve tried without success to hard code images in WordPress pages. The last thing I want to do is use a complete url to the image, I’d rather have it point if possible to my current theme. I’m doing this in the backend of WordPress by writing and editing a page.

    So for example, I have this image that I want to hard code:
    <img src="/images/everybody_dancing_home.jpg" alt="weddings" />

    i’ve tried adding some php to the image tag:
    <img src="<?php bloginfo(‘template_url’); ?>/images/everybody_dancing_home.jpg" alt="weddings" />

    However, when I look at my source code I see this:
    <img src="<?php bloginfo(‘template_url’); ?>/images/everybody_dancing_home.jpg&#8221; alt=&#8221;weddings&#8221; />

    So it looks like the character code is messed up, but when I look in my WordPress page everything appears normal. I’ve also written it out by hand a few times just to check.

    I can’t point you to a site because I’m doing this on a local web server, but any help would be greatly appreciated!

    Thanks
    Mike

    # November 3, 2009 at 4:25 pm

    It sounds like you’re adding the <img> tag in the "Visual" tab. Make sure you are in the "HTML" tab when you add in code like that.

    # November 3, 2009 at 4:27 pm

    Have you installed the Exec-PHP (http://wordpress.org/extend/plugins/exec-php/) Plug-in? I don’t believe you can use PHP in your posts or pages without it installed. I know that it has allowed me to do exactly what you’re wanting to do when I’m linking to items in my posts and pages.

    Hope this helps you!

    # November 3, 2009 at 4:41 pm

    Thanks for the tip on the plug-in!
    Doing exactly as I need now.
    Mike

    # November 3, 2009 at 5:34 pm

    Ah yes! Silly me, of course that would cause problems!

    Glad you got it sorted.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".