You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress自定义插件激活后自定义文章类型未在WP-admin左侧导航栏显示

问题解决方法

核心问题

你提供的代码只完成了自定义文章类型的参数配置,缺少实际执行注册的核心函数调用,这是导航栏不显示的根本原因。

修正后的完整代码

/*
Plugin Name: 自定义电影文章类型
Description: 学习开发用的自定义电影文章类型插件
Version: 1.0
*/

function tutsplus_register_post_type() {
 
    // 电影文章类型配置
    $labels = array(  
        'name' => __( 'Movies' , 'tutsplus' ), 
        'singular_name' => __( 'Movie' , 'tutsplus' ), 
        'add_new' => __( 'New Movie' , 'tutsplus' ), 
        'add_new_item' => __( 'Add New Movie' , 'tutsplus' ), 
        'edit_item' => __( 'Edit Movie' , 'tutsplus' ), 
        'new_item' => __( 'New Movie' , 'tutsplus' ), 
        'view_item' => __( 'View Movie' , 'tutsplus' ), 
        'search_items' => __( 'Search Movies' , 'tutsplus' ), 
        'not_found' =>  __( 'No Movies Found' , 'tutsplus' ), 
        'not_found_in_trash' => __( 'No Movies found in Trash' , 'tutsplus' ), 
    );
 
    $args = array(
        'labels' => $labels, 
        'has_archive' => true, 
        'public' => true, 
        'hierarchical' => false, 
        'supports' => array( 
            'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'page-attributes' 
        ), 
        'rewrite'   => array( 'slug' => 'movies' ), 
        'show_in_rest' => true 
    ); 

    // 新增这行核心注册代码
    register_post_type( 'movie', $args );
}
add_action( 'init', 'tutsplus_register_post_type' );

后续操作步骤

  • 替换原有插件代码后重新激活插件
  • 进入后台「设置」→「固定链接」页面,直接点击「保存更改」,刷新重写规则即可,无需修改任何配置
  • 若仍未显示,确认当前登录账号拥有管理员权限,可切换为超级管理员账号测试

内容的提问来源于stack exchange,提问作者Maha Waqar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 11:54:11