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 trialDawn Foster
1,899 PointsChild Theme won't show images in the media library
Hi Zac:
I just finished the bootstrap to WP course, and have the theme that was created from that project. I have several images in the media library that are being used by this parent theme.
I then followed the instructions in this video of how to make child themes. In the child theme's folder I have the following 4 files (specific details are listed under the question I submitted for this course previously: "Files needed to Create a Child Theme"):
screenshot.png
index.php - (complete copy of the parent's index.php file)
style.css - with comments set for my child and it's parent theme (but no import code)
function.php - with wp_enqueue_style() to enqueue the parent stylesheet
When I activate the new child theme (** with no additonal changes to the theme **), and I try to go to the media library, it doesn't show any images. (The little circle keeps running showng that it is still processing, but it never ends up showing any images) When I tried to upload any images, it gives me and error: "An error occurred in the upload. Please try again later.".
I switched back to the parent theme, and the media library displays fine. When I go back to the child theme, it doesn't display. But I just noticed the problem seems to be just with the grid display. If I select the list display, all the images are there.. even the ones that gave me the error when I tried earlier. I tried uploading another image, and this time it did seem to accept the upload, although the 'crunching' button stayed displaying for a very long time!)
Is there some trick to this? It almost appears to me that the first time the Child theme accesses the library, it has to process all the large images, and it takes a long time before they display? Hence why the processing circle is still displaying? Although I have left it on the grid page for at least 30 minutes, and still no images.
I don't think it is a Database problem, as I can see the grid layout of all the images fine with the parent theme.
I searched the web, and I found others that have had problems with child themes, (with no solution offered), but I find it hard that the child theme is causing this problem, as I didn't make any new changes to it yet!
Any help would be appreciated.
Thanks!
Dawn Foster
1,899 PointsHi Luis:
Because of your request, I had to go back and look at my functions.php file to make sure it was exactly as I expected it to be. It should have been this:
function.php - as follows:
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
But instead, I found that I had added a comment to explain where I got the code!!! Which is what broke the media page. ( I know you are supposed to have this PHP statement at the first line - but while I was testing, I must have put that comment as the first line at some point).
I've checked, and the media page is now working as it should.
Good deduction on your part!
Thanks very much.
3 Answers
Luis Vazquez
6,370 PointsNo problem Dawn!
Zac Gordon
Treehouse Guest TeacherGlad you worked it out!!!
Steve Cafarelli
31 PointsI just had the same problem! And it was the comment I had in there, too. What is the deal with certain comments tripping up the child's function.php file?
Luis Vazquez
6,370 PointsLuis Vazquez
6,370 PointsHi Dawn,
Can you copy and paste in your child theme's functions.php file?
Luis