功能自定义帖子类型中的自定义字段无法正常工作

时间:2017-04-27 04:22:46

标签: wordpress custom-post-type

there is no dropdown list coming from custom fields , no thumbnail feature我一直在尝试将新闻设计为自定义帖子类型,我还在function.php页面中添加了必要的代码。但是自定义字段部分中仍然没有下拉列表。这是我的代码

[![function news_custom_init() {
    $args = array(
      'public' => true,
      'label'  => 'News',
      'has_archive'=>true,
      'supports' => array('title', 'editor', 'description', 'author', 'thumbnail', 'custom-fields')
    );
    register_post_type( 'news', $args );
}
add_action( 'init', 'news_custom_init' );

2 个答案:

答案 0 :(得分:0)

以下是添加自定义帖子类型的基本示例:

add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'acme_product',
    array(
      'labels' => array(
        'name' => __( 'News' ),
        'singular_name' => __( 'News' )
      ),
      'public' => true,
      'has_archive' => true,
      'supports' => array('title', 'editor', 'description', 'author', 'thumbnail', 'custom-fields')
    )
  );
}

答案 1 :(得分:0)

 function news_custom_init() {
 $args = array(
      'public' => true,
      'labels' => array(
                'name' => __( 'Newss' ),
                'singular_name' => __( 'News' )
            ),
      'has_archive'=>true,
      'publicly_queryable' => true,
      'show_ui'            => true,
      'show_in_menu'       => true,
      'query_var'          => true,
      'supports' => array('title', 'editor', 'description', 'author', 'thumbnail', 'custom-fields')
    );
    register_post_type( 'news', $args );
}
}
add_action( 'init', 'news_custom_init' );