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

Static Homepage template doesn't work

Hi there,

I have a little problem with my Home Page Template. I don't have the latest posts from portfolio on my HomePage template and the Menu Button doesn't work.

Here is my code from content-portfolio.php page:


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

$args = array(
    'post_type' => 'portfolio'
    'posts_per_page' => $num_posts  
$query = new WP_Query( $args );


Code from front-page.php and page-portfolio.php

<?php get_template_part('content', 'portfolio'); ?>

Thank you.

Best regards,


5 Answers

I found the problem. I forgot to put the "," afert 'post_type' => 'portfolio'

I had:

$args = array( 'post_type' => 'portfolio' 'posts_per_page' => $num_posts

And It must be like:

$args = array( 'post_type' => 'portfolio', 'posts_per_page' => $num_posts

Carl Sergile
Carl Sergile
16,570 Points

Hey thanks man. Just spent so long trying to figure out why the pages were broken. Thanks a lot for posting this!

I had the same problem. just fixed it.

Thanks !!!!!

Jacobus Hindson
Jacobus Hindson
14,429 Points

Good work catching it yourself. A missed ',' or ';' have certainly cost me an hour or two.

Thank you! Same for me :)

Hi Carl,

You're welcome! I'm glad that I could help you.

Have a nice day!


Dani Tal
Dani Tal
568 Points

Thanks :)

I had the same issue and resolved it as you did