Hi,
I have made some customisations to the Plugin code that allowed me to achieve this (well, the “display child pages” bit) via a simple filter and a shortcode argument. You could certainly pretty easily use it to show sibling pages too.
I made the following adjustment to wp-show-posts.php – line 384:
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );
is now:
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args, $settings ) );
This small change makes it so the $settings are passed through to the ‘wp_show_posts_shortcode_args’ filter, which means then you can make adjustments to the WP Query based on custom settings that you choose to implement via the shortcodes “settings” argument.
In my functions.php I then added the following:
add_filter( 'wp_show_posts_shortcode_args', 'hvydev_display_child_pages_only', 10, 2);
function hvydev_display_child_pages_only( $args, $settings ){
if( is_page() && $settings['show_children'] == true ){
$args['post_parent'] = get_the_ID($post);
$args['orderby'] = 'menu_order title';
}
return $args;
}
Using the above filter, I check that we are looking at a page (using is_page() ) and also check the “settings” for the value of “show_children”. If both are found to be true, I set a new argument on the WP_Query of “post_parent” equal to the ID of the $post (which is the page that the shortcode is called from). For good measure, I have also adjusted the “orderby” parameter of the $args array to be “menu_order title” which just gives me a little more control over how the Child Pages are ordered.
The last piece of the puzzle is adding a custom “settings” argument to my shortcodes when I want to show only children. This is what the shortcode looks like:
[wp_show_posts id="123" settings="show_children=true"]
I hope that all makes sense. Obviously, this solution is a little “hacky” and you will need to be careful when updating the plugin since your change to the apply_filters call on line 384 will be overwritten, but perhaps the plugin developer will see the solution and see it appropriate to update the plugin to include this handy tweak.
Good Luck.
Sam