我有一个函数,可以使用wp\\u list\\u页面在侧栏php文件中显示页面的子级:
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>
我还创建了一个使用查询帖子显示自定义帖子类型的快捷码: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\');
我的问题是,当短代码位于页面中时,它会使子页面不显示。我假设它覆盖了$post变量。我曾尝试使用wp_查询,并为短代码获取_帖子,但我得到了相同的结果。
有办法解决这个问题吗?