WordPress.org

Ready to get started?Download WordPress

Forums

Random post from Custom Post Types -> (fluid) grid (1 post)

  1. r1987
    Member
    Posted 2 years ago #

    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/GLLd8sKA

    Option 2
    two WP_Query, two columns, rewind posts -> see pastebin: http://pastebin.com/YRjU6AXH

    The 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?

    [ Please do not bump, it's not permitted here. ]

Topic Closed

This topic has been closed to new replies.

About this Topic