Wordpress - Pull Latest posts from custom post types

Hello all, I am implementing the popular Nivo Slidebar on my wordpress sidebar and I would need some help with my code.

Basically I just want to show 5 slides which always contain the latest post from each of my review types namely:

  1. os_fashion
  2. os_travel
  3. os_watches
  4. os_gifts
  5. os_games

I am having trouble figuring the code that needs to go on the loop… I figured out CSS, Jquery - I just need the php code which can do the above.

I need to show the image and post title.

Any help would be much appreciated!


Use WP_Query and the post_type attribute. The post_type will be whatever string you used when you registered your custom post type.


Hi Force Flow, this is very useful but i couldnt find an example that tells me how to show only 1 post from each of the 5 custom post types… any help with the actual syntax?


The only method that I can think of is to do 5 different WP_Queries and set the “posts_per_page” attribute to 1 for each of them.

thanks! would your suggestion use less resources than 1 WP Query which lists the 5 latest posts with the tag “latest-posts” ? i.e. I am going to tag all posts with “latest-posts” and the Query will pick the last 5…

Database queries are cheap. They’re designed to run and return results quickly.

Your proposed method puts a lot of burden on you to manage the content manually for a feature in your template that should be automatic.