在没有插件的情况下在 WordPress 中插入自定义帖子类型

问题描述 投票:0回答:1

问题是这样的(此网站出现严重错误。请检查您的网站管理员电子邮件收件箱以获取说明。)

我将代码放在 function.php 中,这

function create_posttype() {
  
    register_post_type( 'movies',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Movies' ),
                'singular_name' => __( 'Movie' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'movies'),
            'show_in_rest' => true,
  
        )
    );
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

我期待在 WordPress 的左侧显示“电影”,例如“帖子、页面、媒体等等”

我的问题是我可能错了什么以及我要做什么来解决这个问题。

我真诚地感谢您的回复。

wordpress wordpress-gutenberg wordpress-shortcode
1个回答
0
投票
add_action('init', 'custom_post');
function custom_post() {
    register_post_type('behandelingen',
        array(
            'label'                 => 'Behandelingen',
            'singular_label'        => 'Behandelingen',
            'hierarchical'          => true,
            'public'                => true,
            'publicly_queryable'    => true,
            'show_ui'               => true,
            'show_in_menu'          => true,
            'query_var'             => true,
            'rewrite'               => array('slug' => 'dfbehandelingen'),
            'capability_type'       => 'post',
            'has_archive'           => true,
            'menu_position'         => 5,
            'menu_icon'             => 'dashicons-networking',
            'supports'              => array('title', 'thumbnail', 'editor', 'page-attributes'),
        )
    );

    
}

希望对你有帮助

© www.soinside.com 2019 - 2024. All rights reserved.