0
我收到所有的帖子类型的蛋糕。我需要通过post_id发布。以下是我的自定义帖子类型代码。我的网址是http://localhost:85/wordpress/?cake=cake 我需要的是http://localhost:85/wordpress/?cake=19和post_id = 19的帖子应该出现。Wordpress CPT - 如何使用post_id来显示帖子而不是帖子类型?
// making custom post type
function my_custom_post_cakes() {
// setting up labels for custom post type
$labels = array(
'name' => _x('Cakes', 'post type general name'),
'singular_name' => _x('Cake', 'post type singular name'),
'add_new' => _x('Add New', 'cake'),
'add_new_item' => __('Add New Cakes'),
'edit_item' => __('Edit Cake'),
'new_item' => __('New Cake'),
'all_items' => __('All Cakes'),
'view_item' => __('View Cake'),
'search_items' => __('Search Cakes'),
'not_found' => __('No cakes found'),
'not_found_in_trash' => __('No cakes found in the Trash'),
'parent_item_colon' => '',
'menu_name' => 'Cakes'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our cakes products data',
'public' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'capability_type' => 'post',
'publicly_queryable' => true,
'rewrite' => array('slug' => 'cake'),
'supports' => array('title','thumbnail', 'excerpt', 'comments'),
'has_archive' => true,
);
register_post_type('cake', $args);
}
add_action('init', 'my_custom_post_cakes');