我有一个自定义的帖子类型:
function thfo_register_cantine() {
$labels = array(
\'name\' => \'Cantines\',
\'singular_name\' => \'Cantine\',
\'menu_name\' => \'Cantine\',
\'all_items\' => \'Tous les Menus\',
\'add_new\' => \'Ajouter un menu\',
\'add_new_item\' => \'Ajouter un menu\',
\'edit\' => \'Modifier\',
\'edit_item\' => \'Modifier le menu\',
\'new_item\' => \'Nouveau menu\',
\'view\' => \'Voir\',
\'view_item\' => \'Voir le menu\',
\'search_items\' => \'Chercher un menu\',
\'not_found\' => \'Rien de trouver\',
\'not_found_in_trash\' => \'Non trouvé dans la corbeille\',
);
$args = array(
\'labels\' => $labels,
\'description\' => \'\',
\'public\' => true,
\'show_ui\' => true,
\'has_archive\' => true,
\'show_in_menu\' => true,
\'exclude_from_search\' => false,
\'capability_type\' => \'post\',
\'map_meta_cap\' => true,
\'hierarchical\' => false,
\'rewrite\' => array( \'slug\' => \'cantine\', \'with_front\' => true ),
\'query_var\' => true,
\'supports\' => array( \'title\' ),
\'show_in_rest\' => true,
\'publicly_queryable\' => true,
\'show_in_admin_bar\' => true,
\'show_in_menu\' => true,
\'show_in_admin_menu\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
);
register_post_type( \'cantine\', $args );
}
在上
front-page.php
, 如果我问
get_posts( array(\'post_type\' => array( \'cantine\' ),\'posts_per_page\' => 2,));
我有两篇帖子,但如果我问
get_posts( array( \'post__in\' => $ids, \'posts_per_page\' => 5 ) );
哪里
$ids
是一个带有我的CPT ID的数组,那么,我没有任何结果。。。
你知道为什么吗?
非常感谢