Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Samuel Johnson
Samuel Johnson
9,152 Points

Wordpress query..

Ive been a very basic custom theme for Wordpress and two things which are really annoying me..

-When i change anything in the style.css on my sublime editor its not showing through on chrome? (Ive double checked im editing the same file)

-My images are not loading even though ive checked where the file is directing them and it says they are right (although when looking in the inspector it doesnt show the little preview that normally comes up when you hover over a img link)

These are probably a very basic problem just very frustrating as the html version of the site ive got is perfect...

4 Answers

are you working on a local environment?

for images, make sure you are using the wordpress function get_template_directory_uri() in all of your src links. This function enables the right path to the files to be reached.

Samuel Johnson
Samuel Johnson
9,152 Points

Sorry just saw this, yes its a local server.

I hadnt added the "get_template_directory_uri()" like this right:

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

:)

Samuel Johnson
Samuel Johnson
9,152 Points

Just to confirm this worked perfectly! thanks

an image tag might look like this:

<img src="<?php echo get_template_directory_uri(); ?>/images/image.jpg" />
Samuel Johnson
Samuel Johnson
9,152 Points

Thanks, when copying the above post thats what i did but forgot the ''' bits!

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Okay, couple questions here:

  • Do you have any caching plugins installed?
  • Where are you hosting the site?
  • When you make the changes via the Appearance > Editor do the changes show up?
  • Do you mean images you upload via the admin area or ones in your themes folder? If your theme folder, what code are you using to link to them?

Thanks!

Samuel Johnson
Samuel Johnson
9,152 Points

Hi Zac,

Thanks for your response;

  • The site is being hosted locally using Mamp
  • I highly doubt i have any caching plugins, the only two plugins are the Custom posts and the ACF one (maybe this is not what you mean)
  • The changes seem to be there on the editor section but dont show up on the browser..
  • I have a feeling its the code linking to the images, im using ".../img/filename.png" which is working fine when im loading the images from CSS as a background image in a Flexslider. I do want to load them from the admin area eventually but i think that would another question as i want the images to show up on the front-page.php from a custom field in the admin area.

Thanks again!

Samuel Johnson
Samuel Johnson
9,152 Points

This was a simple error that i had still had a style.css file i was editing when the actually file being loaded into the script was in my css file, when transferring them across i forgot to save in the new directory.