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:
os_fashion
os_travel
os_watches
os_gifts
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!
thanks
Andy
force
March 25, 2013, 5:52pm
2
Use WP_Query and the post_type attribute. The post_type will be whatever string you used when you registered your custom post type.
https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters
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?
thanks
Andy
force
March 25, 2013, 8:53pm
4
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…
force
March 26, 2013, 4:43am
6
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.