Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Homepage

Not all portfolio pieces are showing on home page

I have 13 portfolio pieces and only 10 of them are showing on the home page. Do I need to code something or is there a setting that I missed somewhere?

4 Answers

Hi Eric,

I don't think there is a limit set on these from the tutorial.

One thing to check would be that all 13 portfolio pieces have a featured image set against them.

EDIT:

If you haven't reached that video yet I've just had a thought on what it could be.

The default posts per page is set to 10.

Can you check Settings > Reading to see what number of posts the Blog pages show at most is set to please? If it is set to 10 can you increase it to say 15 and see if that makes a difference please? You should be able to revert this back when you reach the later videos.

-Rich

Paul Roberts
Paul Roberts
7,928 Points

Had this exact question and saw your answer regarding checking a featured image set against them! D'oh! Thanks for accidentally helping me out :D

Haha no problem. Glad I could accidentally help :)

-Rich

Hi Rich,

All of the images have featured images set. When I add a new piece it boots the tenth piece out so there is always 10 images. That's why I was wondering if there was a setting or something I missed.

Hi Eric,

Can you post your code please?

Thanks

-Rich

Hi Eric,

One other thing to check in the meantime would be content-portfolio.php (if you're at that stage). In a later video this includes:

$num_posts = ( is_front_page() ) ? 4 : -1;

This will mean that on the home page 4 portfolio pieces show but normally all pieces will appear.

It may be related to this.

-Rich

Hi Rich,

I did not make it to the video with the content-portfolio.php file yet.

Here is my page_portfolio.php:

<?php get_header(); ?>

          <!-- Content Wrapper -->
          <div class="content-wrapper large-12 columns clearfix" data-equalizer-watch>

            <?php


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

            $query = new WP_Query($args);

            ?>

            <!-- Gallery Thumbs -->
            <div id="effect-1" class="row small-collapse medium-collapse large-collapse full-width img-hover" data-equalizer-watch>

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

              $image_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );

              ?>
              <div class="img small-12 medium-6 large-3 columns left hover">                
                <a href="<?php echo $image_url; ?>" class="fresco"><?php the_post_thumbnail('thumbnail'); ?></a>
                <div class="overlay">
                  <span class="expand"><?php the_title(); ?></span>
                  <a class="close-overlay hide">x</a>
                </div>                
              </div>
              <?php endwhile; endif; wp_reset_postdata(); ?>                                                       
            </div>
            <!-- End Gallery Thumbs -->                  

<?php get_footer(); ?>

I created my own html based off of foundation.

Hi Eric,

Just updated my original answer above based on your feedback.

-Rich

Hi Rich,

The amount of blog post setting is it!

Thank you very much for taking the time to help.

No problem, I should have thought of that earlier really but narrowing the stage you were at in the course helped :)

-Rich