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

Pedro Lucas Da Silva Cunha
Pedro Lucas Da Silva Cunha
5,276 Points

Problem with Work page in wordpress theme building project.

I've been wracking my brain for a little while on this problem. So I'm up to the section called "convert custom post type listing template". Everything is working well except for the images from the 'hompage_slider_image'. At first I figured it was some sort of error with my back end code. I went back and rewatched the videos and didn't find much except for that I misspelled homepage_slider_image. Still didn't work. I then realized I hadn't loaded any images into my projects. I did this and tried again, still didn't work. Any idea where I should start to fix this? Zac Gordon any ideas/tips?

7 Answers

Chris Dziewa
Chris Dziewa
17,781 Points

Could you post your code for the work page here so that we can see if there is something incorrect? Also make sure that when you go to your admin panel > custom fields section, that each of the fields you are using on your work page as a parameter is the same as the field name you created.

Chris Dziewa
Chris Dziewa
17,781 Points

Let me go back a few videos and I'll see if I can find out any problem areas. I'm newish to Wordpress, but I didn't really have problems with that part. I, too, used the wrong name for slider and button on the work page but from what I see here, everything is correct. It's a little more tricky to help with Wordpress themes on here since there are so many files to look at but I will do my best to help you. Are the images that you have uploaded showing up on the edit page for each work project? Also, what is showing up in the image tag src for each project in the source code for the work page? One thing I just saw is that your div class for each project doesn't have a grid size. Maybe the images aren't being given any room. What is showing up right now?

Pedro Lucas Da Silva Cunha
Pedro Lucas Da Silva Cunha
5,276 Points

Alright so I revisited the problem and went once again through the steps in the tutorial (Zac's voice is a kinda funny fast forwarded) and it worked. Apparently I had a box ticked in the field that said to display the image as an object. It had to be displayed as a url. So that fixed it and it now shows up correctly (as a url) in the code. Thanks Chris, you're awesome.

Chris Dziewa
Chris Dziewa
17,781 Points

Awesome man, glad you got it working!

Pedro Lucas Da Silva Cunha
Pedro Lucas Da Silva Cunha
5,276 Points
<?php 

/*

    Template Name: Work Page

*/


get_header(); ?>

<div class="sixteen columns clearfix">

<?php

    $args = array(
        'post_type' => 'work'
    );

    $the_query = new WP_Query( $args );

?>


<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

    <div class="spotlight project" style="background-color: <?php the_field( 'background_color' ); ?>">

        <a href="<?php the_permalink(); ?>">
            <img src="<?php the_field( 'homepage_slider_image' ); ?>">
        </a>

        <h4>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </h4>


        <?php the_field( 'description' ); ?>

        <p>
            <a class="btn blue" href="<?php the_permalink(); ?>" style="background-color: <?php the_field( 'button_color' ); ?>">
                View Project &rarr;
            </a>
        </p>

    </div>

<?php endwhile; else: ?>

    <p>There are no posts or pages here</p>

<?php endif; ?>

</div>

<?php get_footer(); ?>

That's what I have in the work.php file. I'll type out what I have for the Field group, which I double checked and found no errors(been at this all day so I may have missed something).

Field Label: Homepage Slider Image
Field name: homepage_slider_image
Field Type: Image
Instructions: Upload the image to appear for this project on the homepage slider.
Required: Yes
Return Value: Image Object
Preview Size: Medium
Library: All
Conditional Logic: No

I hope we can fix this Chris. Thanks.

Pedro Lucas Da Silva Cunha
Pedro Lucas Da Silva Cunha
5,276 Points

When I click on each seperate work file the images that I loaded do work. That part is working fine. However, when I look at the overall work page(work.php) I see broken images. It's a little icon of a ripped image. It's the one you would get if the source of the image changed (moved to a new folder or something) and now the website can't find it. I'm assuming that the website is having trouble "finding" this photo. In regards to the grids, I'm working off the skeleton framework (check it out at http://www.getskeleton.com/) it's an awesome framework. Anyway, it's based on columns ( 1-16 columns and half columns.) Take a look at the code displaying in my browser: http://tinypic.com/r/1zeiot5/5

Thanks again Chris.

Chris Dziewa
Chris Dziewa
17,781 Points

There seems to be nothing wrong with that file. The strange thing about the image tag src is that it seems to have an array in it. Is one of your loops on another file incorrect?

Chris Dziewa
Chris Dziewa
17,781 Points

Could you try re-uploading the homepage slider images?

Pedro Lucas Da Silva Cunha
Pedro Lucas Da Silva Cunha
5,276 Points

Yea, I didn't even notice that array the first time. Alright I'm going to try re-uploading the homepage slider. I'll let you know if that fixes it.