add_action('init', 'my_post_type_mytype');
function my_post_type_mytype() {
register_post_type( 'mytype',
array(
'label' => __('Mytype', 'My theme name'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'menu_position' => 5,
'rewrite' => array(
'slug' => 'services-view',
'with_front' => FALSE,
),
'supports' => array(
'title',
'thumbnail',
'editor')
)
);
}
//调用
$args = array(
'post_type' => 'Mytype',
'numberposts' => $num,//取到数量,其他参数可以查看 get_posts() 函数
)
$posts = get_posts($args);