我试图显示自定义的子页面post_type
页我发现了一个适用于标准WordPress“页面”的短代码post_type
, 但不适用于自定义帖子类型。
以下是我在覆盖函数文件中放置的短代码:
add_shortcode( \'my_childpages\', \'my_list_child_pages\' );
function my_list_child_pages() {
global $post;
if ( is_page() && $post->post_parent )
$childpages = wp_list_pages( \'sort_column=menu_order&title_li=&child_of=\' . $post->post_parent . \'&echo=0\' );
else
$childpages = wp_list_pages( \'sort_column=menu_order&title_li=&child_of=\' . $post->ID . \'&echo=0\' );
if ( $childpages ) {
$string = \'<ul>\' . $childpages . \'</ul>\';
}
return $string;
}
如果我放置[my_childpages]
“页面”上的短代码post_type
对于子页面,它成功地在链接列表中显示所有子页面。但如果我添加到自定义post_type
(例如,“随笔”),它没有。我在其他地方看到,可能代码不承认自定义$post_type
, 并需要添加一个参数,但我不确定如何编辑上述代码以满足要求。我尝试了几次编辑,但都失败了。
如有任何建议,我们将不胜感激!