I have a function to display the children of the page in the sidebar php file using wp_list_pages:
I have also created a shortcode that shows a custom post type using query posts:Code:global $post; ?> <div id="subChildren"> <?php if($post->post_parent) $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?> <ul id="submenu"> <?php echo $children; ?> </ul>
The problem I have is that when teh shortcode is in a page it makes the sub pages not show up. I assume it is overriding the $post variable.Code:function casestudy_shortcode() { extract(shortcode_atts(array( 'type' => 'case_studies', 'limit' => '1', 'case' => '', 'size' => 'small' ),$atts)); //The Query query_posts('post_type='.$type.'&showposts='.$limit.'&p='.$case); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); //return sb_post_image('100','100'); //the_post_thumbnail('portfolio'); return "<div class='".$size."'><a href=\"".get_permalink()."\">".get_the_title()."</a>" . get_the_excerpt() ."</div>";; endwhile; else: endif; wp_reset_query(); } add_shortcode('casestudy', 'casestudy_shortcode');
I have tried using wp_query and get_posts for teh shortcode but i get the same result.
Is there a way around this?


LinkBack URL
About LinkBacks
Reply With Quote



