I am trying to display random child pages of a parent page, but I get random posts which I dont want to be included in the display area.
$my_query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1', 'pagename=guide') );
So, what I want is to display random child pages of a parent page who slug is guide, but instead I get random posts which is quite different from what I want. Any help would be appreciated. Thanks 🙂
This is working for me. the
post_type
is the important part since otherwise it doesn’t seem WP will query against the pages. The post_parent should be the integer id of your page.This worked for me:
Hope this helps!