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 WordPress Theme Development Custom Homepage Templates in WordPress A Static Homepage Template

Debby Beachy
PLUS
Debby Beachy
Courses Plus Student 2,096 Points

Conditional statements to control the loop

The code:

<?php
                        $num_posts = ( is_front_page()  ) ? 4:-1;
                     $args = array(
                     'post_type' => 'portfolio',
                     'posts_per_page' => $num_posts
                     );

I found this works really nice, however IF I want 3 images this conditional statement takes one of the images out of the center of the 4 leaving a big ugly hole where an image use to be. If I want 5 images and not 4 the 5th image shows up on the left side second row. It should be on the right side second row.

I'm not far enough along yet to understand why this happens or what to do about it.

1 Answer

Andrew Shook
Andrew Shook
31,709 Points

This sounds like a problem with html and css. Could you post the code for the template file you are using.

Debby Beachy
Debby Beachy
Courses Plus Student 2,096 Points

Hi Andrew, Thank you for noticing my question, but I have worked through the problem. Debby

Debby, can you share your solution please?
I'm curious as to how you addressed the issue.