Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress CPT-如何使用post_id显示post而不是post类型?_Php_Wordpress - Fatal编程技术网

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

Php Wordpress CPT-如何使用post_id显示post而不是post类型?,php,wordpress,Php,Wordpress,我得到了所有的邮政类型的蛋糕。我需要邮寄地址。下面是我的自定义邮寄类型代码。我的网址是 我需要的是和post_id=19的post应该出现 // making custom post type function my_custom_post_cakes() { // setting up labels for custom post type $labels = array( 'name' => _x( 'Cakes', 'post type gene

我得到了所有的邮政类型的蛋糕。我需要邮寄地址。下面是我的自定义邮寄类型代码。我的网址是 我需要的是和post_id=19的post应该出现

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

这是将永久链接设置为默认值的最简单方法。 请参见路径: 设置=>permalink,设置默认值。 谢谢