WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Image Src working on index page but not on other pages (6 posts)

  1. jboarini
    Member
    Posted 1 year ago #

    When I insert an HTML image tag in index.php using the following code, it shows up with no problem:

    <img src="<?php bloginfo( 'template_directory' ); ?>/images/small/feature1.jpg">

    However, when I edit a page using the dashboard and paste that same code in the HTML editor, the image stops showing up.

    Please help!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You cannot use PHP in either of the WordPress editors. You have to use hard coded urls.

  3. Jay Hoffmann
    Member
    Posted 1 year ago #

    PHP is automatically parsed in the dashboard so it does not render PHP code very well. This is for good reason, it is generally not a good practice.

    If you are trying to upload images, you can just use the Media Uploader located directly above the HTML Editor window in your dashboard or you can try searching for a plugin that will allow you to do this.

  4. jboarini
    Member
    Posted 1 year ago #

    Ok, that clears it up. I have a gallery that I really like in my regular page, here:

    jonathanboarini.com/works.html

    I assume then that the best solution would be to simply create a page template and use that one correct? Thanks for your help!

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    Yeah, if you are going to custom set up pages with pictures, unique functionality, etc., a template is the way to go

  6. jboarini
    Member
    Posted 1 year ago #

    Excellent, thanks for your help guys!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags