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 trialMadalin Milea
12,469 PointsStatic 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:
<?php
$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,
Madalin
5 Answers
Madalin Milea
12,469 PointsI 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
);
Jacobus Hindson
14,429 PointsGood work catching it yourself. A missed ',' or ';' have certainly cost me an hour or two.
Madalin Milea
12,469 PointsThank you! Same for me :)
Madalin Milea
12,469 PointsHi Carl,
You're welcome! I'm glad that I could help you.
Have a nice day!
Madalin
Dani Tal
568 PointsThanks :)
I had the same issue and resolved it as you did
Carl Sergile
16,570 PointsCarl Sergile
16,570 PointsHey thanks man. Just spent so long trying to figure out why the pages were broken. Thanks a lot for posting this!
eunji jung
3,456 Pointseunji jung
3,456 PointsI had the same problem. just fixed it.
Thanks !!!!!