Timeline for Display posts in random post types
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 13, 2014 at 14:56 | answer | added | s_ha_dum | timeline score: 3 | |
Jan 13, 2014 at 14:32 | history | edited | s_ha_dum | CC BY-SA 3.0 |
improved code formatting
|
Jan 13, 2014 at 13:14 | comment | added | birgire |
But I think you should use two get_posts() call, one for each custom post type, and then use PHP code to loop through them to get the exact p1, p2, p1, p2, ... order you are seeking. To get two random post types you can try: array_rand( get_post_types( $args ), 2 ); . You might need to filter the output with $args . See the Codex for more information on that.
|
|
Jan 13, 2014 at 13:02 | comment | added | Balas | can u explain some little bit code to display random post type's posts | |
Jan 13, 2014 at 13:00 | comment | added | birgire |
The functions get_post_types() and rand() might help you with the first part of selecting two random post types. But since you're ordering by post date, you might only get results from a single post type (e.g. p1)
|
|
Jan 13, 2014 at 12:56 | comment | added | birgire |
... or you want to feed the get_posts() with two random post types, and order the result by the even/odd pattern?
|
|
Jan 13, 2014 at 12:49 | comment | added | birgire |
What about 'orderby' => 'rand' instead? But I don't follow your random criteria. You want to order by random post type but still have it in even/odd order.
|
|
Jan 13, 2014 at 12:44 | comment | added | Balas | birgire can u check the code and give ur idea? | |
Jan 13, 2014 at 12:43 | history | edited | Balas | CC BY-SA 3.0 |
added 449 characters in body
|
Jan 13, 2014 at 12:03 | comment | added | birgire | Is it for a main query? Please show the code you got so far? | |
Jan 13, 2014 at 9:52 | history | asked | Balas | CC BY-SA 3.0 |