Wordpress CPT - 如何使用post_id显示帖子而不是帖子类型?

时间:2015-03-25 04:35:18

标签: php wordpress-plugin wordpress

我得到了所有邮政类型的蛋糕。我需要post_id发帖。以下是我的自定义帖子类型代码。我的网址是http://localhost:85/wordpress/?cake=cake 我需要的是http://localhost:85/wordpress/?cake=19,post_id = 19的帖子应该会出现。

// 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' );

1 个答案:

答案 0 :(得分:0)

最简单的方法是将永久链接设置为默认值。 看路径:
Settings=>permalink , set the default.
谢谢,