Making this php function random
-
Hi, this function, is from the wp_random quote plugin, it outputs a list of all quotes, ordered by id. How can i make it to output the list in a randm order…
i know this is a minor code change but i can’t remember how it’s done.
here is the function:
function wp_quotes_page($data)
{
$start = strpos($data, WP_QUOTES_PAGE);if ( $start !== false )
{
ob_start();global $wpdb;
$sql = "select * from " . WP_QUOTES_TABLE;
$result = $wpdb->get_results($sql);
if ( !empty($result) )
{
$count = 0;
foreach ( $result as $row )
{
if ( $count++ > 0 )
echo "<hr class=\"wp_quotepage_hr\">n";wp_quotes_spew($row, 'class="wp_quotepage"', 'wp_quotepage_quote', 'wp_quotepage_author');
}
}
echo "<div class=\"wpquotes_poweredby\">Powered by <a href=\"https://www.zombierobot.com/\">Zombie Robot wp-quotes plugin</a>.</div>n";$contents = ob_get_contents();
ob_end_clean();$data = substr_replace($data, $contents, $start, strlen(WP_QUOTES_PAGE));
}return $data;
}
add_filter('the_content', 'wp_quotes_page', 10);
?>Thanx
- The topic ‘Making this php function random’ is closed to new replies.