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

Brodie Capel
Brodie Capel
16,365 Points

Adding Content Custom Places - Part 2

IM STUCK! im doing The how to build a wordpress theme class, im up to the video Adding Content Custom Places - Part 2. in this video we add a recent post, a featured post and a recent work section to the front-page.php file of our template.... i have the featured and recent posts working... but when ever I do the recent work section... i have done it like 6 times as the video says.... it displays all my work.. not just one as it should? any ideas?!?!

1 Answer

Brodie Capel
Brodie Capel
16,365 Points

Thanks for you time... but this is quite what i'm talking about.... on the home page of the project there is supposed to be a display of a recent project. i have everything working but its showing all 4 projects.. not just one.. I think im just going to go over the video again and recode try and iron out a bug.... i probs only missed one single bracket or something. :P rookie mistakes.. make things brake.

Brodie Capel
Brodie Capel
16,365 Points

Just for the record.... I still couldn't get it after deleting the files and re-coding from scratch.... however i came up with a work around...

'post_per_page' => 1

fixed it.... dont know why i didnt think about it sooner.... after re-visting the video.. they didnt include this.. but if it works... it works.

Pedro Baumann
Pedro Baumann
12,815 Points

Brodie, that is exactely what they forgot to add to the video, however, When I add that (was my first idea) it just crashes php!!!

Anyone else has a clue about why this might be? It's not a syntax error, I have c/p the same code I used before in other parts:

<?php 

            $args = array(
                'post_type' => 'work'
                'posts_per_page' => 1,
            );
            $the_query = new WP_Query( $args );

?>
Pedro Baumann
Pedro Baumann
12,815 Points

nevermind...just spoted the mising comma.....(bangs head against screen...)

Jeesun Kim
Jeesun Kim
4,866 Points

I have the same problem. 'post_per_page' doesn't work for me. Ahhh where is this missing comma for me?

Jeesun Kim
Jeesun Kim
4,866 Points

Actually 'posts_per_page' worked. But why didn't it work without it?