I’m using the following snippet to get a random post from the database, and then display a link to it.
$neon_story_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'static' AND post_parent = '2' ORDER BY RAND() LIMIT 1");
$neon_story = $wpdb->get_row("SELECT post_name, post_title FROM $wpdb->posts WHERE ID = $neon_story_ID", ARRAY_A);
Is this the most optimal way to do things? Could it be made more efficient?
- The topic ‘Is there a faster way to display random link to post?’ is closed to new replies.