Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.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高级自定义帖子未在后端显示_Php_Arrays_Wordpress_Custom Post Type_Posts - Fatal编程技术网

Php WordPress高级自定义帖子未在后端显示

Php WordPress高级自定义帖子未在后端显示,php,arrays,wordpress,custom-post-type,posts,Php,Arrays,Wordpress,Custom Post Type,Posts,这是代码,第五个也是最后一个代码没有显示在管理CP面板中。所有其他的都很好,但是当我尝试添加第五个时。什么也没出现。不确定是否有限制或什么,似乎不是从我读到的 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'Slides', array( 'labels' => array(

这是代码,第五个也是最后一个代码没有显示在管理CP面板中。所有其他的都很好,但是当我尝试添加第五个时。什么也没出现。不确定是否有限制或什么,似乎不是从我读到的

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'Slides',
        array(
            'labels' => array(
                'name' => __( 'slides' ),
                'singular_name' => __( 'slide' )
            ),
            'public' => true,
            'has_archive' => true,
        )
    );

    register_post_type( 'Programs',
        array(
            'labels' => array(
                'name' => __( 'programs' ),
                'singular_name' => __( 'program' )
            ),
            'public' => true,
            'has_archive' => true,
        )
    );

    register_post_type( 'Boards',
        array(
            'labels' => array(
                'name' => __( 'Boards' ),
                'singular_name' => __( 'sponsor' )
            ),
            'public' => true,
            'has_archive' => true,
        )
    );

您的代码工作得很好,您只是忘记了代码末尾的右括号
}
和slug post类型中的一些错误(小写):

add_action('init','create_post_type');
函数create_post_type(){
寄存器后类型('slides',//数组(
'name'=>_u('Slides'),//_('Slide')//true,
“has_archive”=>true,
)
);
register\u post\u类型('programs',//数组(
'name'=>_('Programs'),//_('Program')///true,
“has_archive”=>true,
)
);
寄存器\u post\u类型('boards',//数组(
“名称”=>“(“板”),
'singular_name'=>\('Board')//true,
“has_archive”=>true,
)
);
}//数组(
'name'=>$slugs,
“单数名称”=>$slug),
“public”=>正确,
“has_archive”=>true)
);
}
}

参考资料:


线路板自定义柱不会显示在后端
add_action( 'init', 'create_post_type' );
function create_post_type() {
  register_post_type( 'slides', // <== here to lowercase (slug)
    array(
      'labels' => array(
        'name' => __( 'Slides' ), // <== here 1st letter uppercase
        'singular_name' => __( 'Slide' ) // <== here 1st letter uppercase
      ),
      'public' => true,
      'has_archive' => true,
    )
  );

    register_post_type( 'programs', // <== here to lowercase (slug)
    array(
      'labels' => array(
        'name' => __( 'Programs' ), // <== here 1st letter uppercase
        'singular_name' => __( 'Program' ) // <== here 1st letter uppercase
      ),
      'public' => true,
      'has_archive' => true,
    )
  );

    register_post_type( 'boards', // <== here to lowercase (slug)
    array(
      'labels' => array(
        'name' => __( 'Boards' ), 
        'singular_name' => __( 'Board' )  // <== here singular
      ),
      'public' => true,
      'has_archive' => true,
    )
  );
} // <== forgetted this
add_action( 'init', 'create_post_type' );
function create_post_type() {
    $arr = array('abcdef','bcdefg','cdefgh','defghi','efghij','fghijk','ghijkl','hijklm','ijklmn','jklmno');
    for( $i = 0; $i < 10; $i++ ) {
        $slug = $arr[$i]; 
        $slugs = $arr[$i].'s';
        register_post_type( $slug,
            array( 
                'labels' => array(
                    'name' => $slugs,
                    'singular_name' => $slug ),
                'public' => true,
                'has_archive' => true ) 
        );
    }
}