I'm trying to create a shortcode to display child pages, so far works like charm, however, I passing a value called 'parent' as response for 'post_parent', by default I need to display the current post ID, however if the user pass the parameter for sample [shortcode parent=5] the shortcode display childs of the post with ID 5.
Problem: If I set parent to X value, so far works like charm, however by Default, it doesn't assign any parameter.
Any guessing?
Thanks in advanced.
This is the code, I don't think is necessary to copy all since is really long, I'm just copying the query part.
function andrew_child_loop_shortcode ( $atts ) {
extract ( shortcode_atts (array (
'parent' => **$thePostID**,
'posts' => 20
), $atts ) );
$output = '<div class="clear"></div>';
$args = array(
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => $parent,
'post_type' => 'page',
'posts_per_page' => $posts
);
**global $post;
$thePostID = $post->ID;**
$andrew2_query = new WP_Query( $args );
What is marked with black **, is what I thought could be the solution, however is not working.
global $post; $thePostID = $post->ID;to the top of the function. – Joshua Abenazer Dec 6 '11 at 5:59