Get random posts; a simple, more efficient approach.
.
MySQL queries that use ORDER BY RAND() can be pretty challenging and slow on large datasets. This function is an alternative method for getting random posts, though it’s not as good but at least it won’t destroy your site :).
Parameters
Name | Type | Description |
---|---|---|
$number | int | Optional. Amount of random posts to get. Default 1. |
$post_type | string | Optional. Specify the post_type to use when randomizing posts. Default 'post'. |
$return_ids | bool | Optional. To just get the IDs, set this to true, otherwise post objects are returned (the default). |
Return Value
array