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

Morten Korshavn
Morten Korshavn
936 Points

Post snippet for Wordpress!

Hi there!

I wonder if anyone could help me with 2 small problems i'm having in WP.

  1. At my frontpage/landing page in WP i need it to show the 3 latest news fromt the post function. Any snippet of code for that?

  2. Some of my of my other pages at the website, needs to be split into categories. So if you for example visit the "design" page, i'll only need the post from the category design to show up.

Hope someone can help with this small problem.

Cheers!

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hey!

First off, you will want to use the WP_Query function for creating a custom loop that only shows the latest three blog posts. Check out this workshop on WP_Query for some more info on specifics.

You can also use this approach for creating custom category listing pages. However, WordPress automatically creates category listing pages for you. Depending on what your URL structure looks like, you should be able to do something like this yoursite.com/category/thecategoryslug and it will automatically generate a page with all of those posts.

In your menu sections in the admin area you can also create links directly to category pages.

Morten Korshavn
Morten Korshavn
936 Points

Hi Zac Gordon !

thanks for the reply (and so quickly, didn't expect that). I'll try to look into the worksho.