WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] adding images to static pages (6 posts)

  1. comlucom
    Member
    Posted 1 year ago #

    its been weeks and i cant find the answer: i'm adding images on a static page but all that shows up is the alt word. where am i supposed to put the images to be able to have them show up? ive tried everything i can think of, any help would be great - thanks in advance - rob

  2. comlucom
    Member
    Posted 1 year ago #

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    <?php
    /*
    Template Name: welcome
    */
    ?>
    
    <?php get_header(); ?>
    
    Here's my welcome page! 
    
    <img src="images/stars.gif" width="212" height="226" alt="stars">
    
    <?php get_footer(); ?>

    this is the code - why wont that work? - anyway thanks again

  3. rikardo85
    Member
    Posted 1 year ago #

    Try entering it as

    <img src="<?php echo get_template_directory_uri();?>/images/stars.gif">

    It should automatically take the width and height of the image uploaded in the images folder.

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  4. comlucom
    Member
    Posted 1 year ago #

    thanks a lot - i'll give that a shot tonight and let you know

  5. WebTechGlobal
    Member
    Posted 1 year ago #

    Solution is probably posted. But just to avoid possible confusion I'll mention that get_template_directory_uri() is the path to your current active theme. So your images folder shown in your code must not be in your parent directory.

    Chances are you know this comlucom but I don't like to assume anything when it comes to troubleshooting.

    If you still have problems. Try visiting the image directly and confirm the full path. Then paste that into your theme. If your theme is not going to be used anywhere else, it is fine.

    If get_template_directory_uri() works for you. You may still want to replace it with the full path created by get_template_directory_uri(). Less use of functions makes for a faster theme.

  6. comlucom
    Member
    Posted 1 year ago #

    holy crap - that worked rikardo85 - thanks so much - i cant believe how difficult that was to find - and thanks webtech too, i never wanted to be the guy posting questions but now i'm wondering why ...

Topic Closed

This topic has been closed to new replies.

About this Topic