Una solución de menú es posible, y la abordaré al final, pero otra es agregar los enlaces personalizados con el gancho views_edit-$post_type
.
Mi cuenta y Checkout son dos páginas principales. Sus enlaces utilizarán los ID de página codificados: edit.php?post_type=page&checkout=1669
y capturaremos el parámetro $_GET['checkout']
para llamar a un gancho pre_get_posts
.

#Calledonlyin/wp-admin/edit.php*pagesadd_action('load-edit.php',function(){#Notourpost_type,bailoutif(get_current_screen()->id!='edit-page')return;#TransientcacheforpagesIDsandCount#usedinbothhooksbellowdo_cache_wpse_77721();#CheckifourQueryVarisdefinedandactivatepre_get_postsif(isset($_GET['account'])||isset($_GET['checkout']))add_action('pre_get_posts','pre_posts_wpse_77721');add_filter('views_edit-page','custom_links_wpse_77721');});/***Onlydisplaycommentsofspecificpost_id*/functionpre_posts_wpse_77721($query){#Justtoplaysafe,butIthinkthehookisquitespecificalycalledif(!is_admin())return$query;global$pagenow;#Ifthere'snocache,bailout$cache=get_transient('custom_page_links');if(!$cache)return$query;#DefinetheIDswewanttoqueryif(isset($_GET['account']))$ids=$cache['account']['ids'];else$ids=$cache['checkout']['ids'];#Here,too,justplayingsafeif('edit.php'==$pagenow&&(get_query_var('post_type')&&'page'==get_query_var('post_type')))$query->set('post__in',$ids);return$query;}/***Addlinktospecificpostcommentswithcounter*/functioncustom_links_wpse_77721($status_links){$cache=get_transient('custom_page_links');$count_checkout=sprintf('<spanclass="count">(%s)</span>',
$cache['checkout']['count']
);
$count_account = sprintf(
'<span class="count">(%s)</span>',
$cache['account']['count']
);
$link_account = 'edit.php?post_type=page&account=1670';
$link_checkout = 'edit.php?post_type=page&checkout=1669';
$link_all = '<a href="edit.php?post_type=page">All</a>';
$separator = 'CUSTOM LINKS ➽';
if( isset( $_GET['checkout'] ) )
{
$status_links['all'] = $link_all;
$status_links['my_sep'] = $separator;
$status_links['account'] = "<a href='$link_account'>My Account $count_account</a>";
$status_links['checkout'] = "<a href='$link_checkout' class='current'>Checkout $count_checkout</a>";
}
elseif( isset( $_GET['account'] ) )
{
$status_links['all'] = $link_all;
$status_links['my_sep'] = $separator;
$status_links['account'] = "<a href='$link_account' class='current'>My Account $count_account</a>";
$status_links['checkout'] = "<a href='$link_checkout'>Checkout $count_checkout</a>";
}
else
{
$status_links['my_sep'] = $separator;
$status_links['account'] = "<a href='$link_account'>My Account $count_account</a>";
$status_links['checkout'] = "<a href='$link_checkout'>Checkout $count_checkout</a>";
}
return $status_links;
}
/**
* Makes the query once every hour
* holds the Parent and Children ID, plus the Children total pages count
*/
function do_cache_wpse_77721()
{
if( !get_transient( 'custom_page_links' ) )
{
# Page 1
$checkout_posts = get_children( 'post_parent=1669&post_type=page' );
// To include the parent ID in the query
$c_ids = array( '1669' );
// Grab the children IDs
foreach( $checkout_posts as $check )
$c_ids[] = $check->ID;
$checkout = array(
'ids' => $c_ids,
'count' => count( $checkout_posts )
);
# Page 2
$account_posts = get_children( 'post_parent=1670&post_type=page' );
$a_ids = array( '1670' );
foreach( $account_posts as $acc )
$a_ids[] = $acc->ID;
$account = array(
'ids' => $a_ids,
'count' => count( $account_posts )
);
# Set transient
$transient = array(
'checkout' => $checkout,
'account' => $account
);
set_transient( 'custom_page_links', $transient, 60*60 );
}
}
Y a continuación se explica cómo agregar un submenú a Páginas , que enlaza directamente con una de las páginas principales. Tenemos que usar jQuery para ajustar los estados activos / inactivos para el menú y el submenú.
add_action('admin_menu', function()
{
add_submenu_page(
'edit.php?post_type=page',
'Checkout',
'Checkout',
'edit_pages',
'custom_parent_page',
function()
{
wp_redirect(admin_url('edit.php?post_type=page&checkout=1669'));
exit;
}
);
});