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

Trent Burkenpas
Trent Burkenpas
22,388 Points

Image not showing up properly, through my custom post.

I created a custom post for a portfolio section. All my fields work except my image field. for some reason when I add an uploaded image to the custom post it does not appear.

When I inspect the webpage it shows the image having width 250px and height of 0. Also when I hover over the link in the inspect element console the image does not appear. I know for a fact that the link for the image is correct. I have no idea what could be the error here.

Here is my loop for my custom post.

<?php

                    $args = array (
                        'post_type' => 'portfolio'
                    );
                    $query = new wp_Query( $args );

                ?>

                <?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
                <div class="portfolio">
                    <img class="portfoliopic" scr="<?php the_field('image'); ?>" />
                    <h2><?php the_field('title'); ?></h2>
                    <p><?php the_field('description'); ?></p>
                    <hr>
                </div>
                <?php endwhile; endif; wp_reset_postdata(); ?>

btw this is a child theme, but I don't think that has anything to do with the error

thanks for the help

Robert Gage-Smith
Robert Gage-Smith
13,977 Points

Surely it should be 'src' not 'scr'?

Trent Burkenpas
Trent Burkenpas
22,388 Points

Robert Gage-Smith

-_- I hate myself right now. Thanks for spotting that out. I cant believe I spent hours looking up solutions, when it was a stupid typo. Once again thank you