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

Gabriel Ward
Gabriel Ward
20,222 Points

Setting image sizes

I'm having real trouble setting the image sizes the way I want them to be in my Wordpress theme. The images in their original state are squares. However I want to crop them to be 300x200. Here is what I believe is the relevant code

home.php
<?php get_header(); ?>
<div class='pageMain'>
<?php while ( have_posts() ) : the_post(); ?>
    <article class='col-group'>
    <?php if( get_the_post_thumbnail() ) : ?>
                        <div class = 'image'>   
                            <div class="feat-img">
                                <?php the_post_thumbnail( array (300, 300) ); ?>
                            </div>

                           <a href="<?php the_permalink(); ?>"> <div class ='text'><h2><?php the_title(); ?></h2></div></a>
                        </div>    
.feat-img img {
    width: 100%;
    margin: 0;
    padding: 0;
    height: auto;
}
functions.php
add_theme_support( 'post-thumbnails' );

Any help would be greatly appreciated.

Christian Moran
Christian Moran
6,514 Points

Gabriel, I don't see anything wrong with your code.. Is this on your local environment or can you provide a url for your site? Now does the thumbnail appear? and what size does it show?

Gabriel Ward
Gabriel Ward
20,222 Points

Hi Christian

It's local development. I want to know how to change the mage to a cropped rectangle