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

Just show the latest (full page) post on homepage

I had a piece of code for the functions.php a few years back that when you went to the main url of the WordPress site ie http://www.mysite.com it automatically loaded up the latest post.

I can't seem to find that code anywhere now and if anyone knows how I could do this that would be awesome.

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

You can just write a custom query with WP_Query that displayed the post you wanted. If you want to put the query in your functions.php file you can wrap it in a function and just call that in your front-page.php template.

Cheers Zac Gordon. Someone on the Facebook Treehouse Group pointed me to an old post I actually made with this link on which does the trick - http://wordpress.org/support/topic/only-show-latest-post-and-comments-on-front-page

Thanks for the time and help :)