Previously we have established that the fastest way to get an ID is using wpdb . So, simply to get a random post link use:

	function eo_get_a_rand_postlink() {
		global $wpdb;
		$rand_post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 1");
		return get_permalink($rand_post_id);
	}
g1rlClipboard01

Leave a Reply

Your email address will not be published.