Guys,
Where am I going wrong here... I know its late as hell over here and I just hit a wall, I've goofed around with post_parent and I just cant get it right. Right now the code below generates a random page from all pages I've created when my button is clicked. What Im looking for is for the button to generate a random page just as it is now but from a list of the CHILD pages. So, basically, I need the code to tell me what the parent of the current page is, then extract the list of CHILD pages that are published, randomly select a page out of that table and then store it in the variable $randomPage. You can see I've got 80% of it done below. Can anyone help me out here? Check the code below.
<?php
$randomPage = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
echo '<a href="'.$randomPage.'"><img src="http://somesite/button.png"></a>';
?>