One random Post from multiple Custom Post Types
-
So I’ve searched the seven seas for this, but i can’t find a tutorial that would explain me this thing in a good way so may-be someone can help me out or address me to some tutorials.
I’m building a movie site that has 9 different custom post types (all working well). But on the index page, id like to show one random post from each custom post type in a grid. The site is fluid and running on its own grid system (columnal 0.82).
Option 1
three WP_Querys for each column -> see pastebin: http://pastebin.com/GLLd8sKAOption 2
two WP_Query, two columns, rewind posts -> see pastebin: http://pastebin.com/YRjU6AXHOption 3
One WP_Query, posts into divs, last div clears right -see pastebin: http://pastebin.com/T2yk1NTYThe problems with these is that they duplicate the CPT sometimes, so you have a 10% chance that all the called out posts are from different CPT’s.
So… what i’d like to do is to display 1 random post from each post type like this:
CPT1 Name | CPT 4 Name | CPT 7 Name |
Random post Thumbnail | Random post Thumbnail | Random post Thumbnail |CPT2 Name | CPT 5 Name | CPT 8 Name |
Random post Thumbnail | Random post Thumbnail | Random post Thumbnail |CPT3 Name | CPT 6 Name | CPT 9 Name |
Random post Thumbnail | Random post Thumbnail | Random post Thumbnail |9 WP_Querys is overkill for this, so may-be someone can share/explain some know-how behind this?! And may-be someone has dealed with fluid grids + wordpress.
Is there a way?
- The topic ‘One random Post from multiple Custom Post Types’ is closed to new replies.