Forums

[resolved] I'm New Here.. Image Problem (9 posts)

  1. Kyle Numann
    Member
    Posted 10 months ago #

    I have run into an interesting roadblock. This is my first experience with WordPress (so far, very fantastic) but I am styling my header, and trying to add some social media icons, but no images will appear.

    I have my header.php, index.php, footer.php, style.css & functions.php files in my theme folder, and an images folder with the .png images I am trying to code into the header.

    Is there some basic aspect of wordpress that I need to enable images?
    I have a background image working just fine via a css style.

    I have the social media items in an
    <ul> though I tried coding them outside of the list to see if that was interfering and still no image luck.

    Any ideas?
    Thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Your images folder should be inside your theme's folder.

  3. Kyle Numann
    Member
    Posted 10 months ago #

    Thanks for the reply esmi.

    Yes, the images folder is inside of the theme folder, just as twentyten & twentyeleven are.

    I have done a good amount of webdesign (though it's been a while) so I understand most of the concepts. It should be a simple img src="images/facebook.png" tag but for some reason it just refuses to show...

    I would link to the example but I am working locally.

    Is there some kind of link issue when a .php page is called from inside another .php page? My index.php loads the header.php which has the image links, but both .php files are in the same directory as the image folder.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    You cannot use relative urls in markup within WordPress. Stick to absolute urls.

  5. Kyle Numann
    Member
    Posted 10 months ago #

    ahh okay... that sure did it... though now I have a new problem.
    Now my code is
    img src="http://localhost/Joby WordPress/wp-content/themes/Origional stripped/images/twitter.png"
    which will obviously break as soon as the site is uploaded...
    How do I work around that?
    Do I have to use the dashboard somehow to include images in my theme?

    Thanks again for your help.

  6. Kyle Numann
    Member
    Posted 10 months ago #

    update- since then I searched for some "relative url" topics and seem to have found the people that were looking for the same solution I was looking for. And what do you know, esmi was there posting helpful information...

    thanks for sending me in the right direction.

  7. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    You need to use WP functions to replace urls such as the site url or the url for the template directory.

    <img src="<?php echo get_stylesheet_directory_uri();?>/images/twitter.png alt="Twitter" />

    I'd also suggest that you get that space out of your theme's folder name. Use a hyphen instead.

  8. Kyle Numann
    Member
    Posted 10 months ago #

    Fantastic. This had me held up for far too long, and I never would have guessed the relative URL's.
    Also, I'm new to this php wizardry... can't wait to become a little more adept.

    Your advice worked like a charm, thanks again.

  9. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    No problem :-)

Reply

You must log in to post.

About this Topic