首页 > 解决方案 > 无法在 wordpress 上使用具有自定义帖子类型的插件

问题描述

我在 Wordpress 中创建了一些新的自定义帖子类型,但是当我想编辑我的帖子时,我无法使用 yoast SEO 之类的插件(它不会出现在管理员中)。这是我生成自定义帖子类型的功能

    public function register_custom_vertical_post_type() {

        // Get verticals from form in the admin with metabox
        $verticals = rwmb_meta("verticals", ['object_type' => 'setting'], 'manage-vertical');

        foreach($verticals as $vertical):
            $name = $vertical["name"];
            $plural_name = $vertical["plural_name"];

            $labels = [
                'name'                     => esc_html__( ucfirst($plural_name), $this->current_theme ),
                'singular_name'            => esc_html__( "{$name}", $this->current_theme ),
                'add_new'                  => esc_html__( 'Add New', $this->current_theme ),
                'add_new_item'             => esc_html__( "Add new {$name}", $this->current_theme ),
                'edit_item'                => esc_html__( "Edit {$name}", $this->current_theme ),
                'new_item'                 => esc_html__( "New {$name}", $this->current_theme ),
                'view_item'                => esc_html__( "View {$name}", $this->current_theme ),
                'view_items'               => esc_html__( "View {$plural_name}", $this->current_theme ),
                'search_items'             => esc_html__( "Search {$plural_name}", $this->current_theme ),
                'not_found'                => esc_html__( "No {$plural_name} found", $this->current_theme ),
                'not_found_in_trash'       => esc_html__( "No {$plural_name} found in Trash", $this->current_theme ),
                'parent_item_colon'        => esc_html__( ucfirst($name) . "" . $name . ":", $this->current_theme ),
                'all_items'                => esc_html__( "All {$plural_name}", $this->current_theme ),
                'archives'                 => esc_html__( ucfirst($name) . " Archives", $this->current_theme ),
                'attributes'               => esc_html__( ucfirst($name) . " Attributes", $this->current_theme ),
                'insert_into_item'         => esc_html__( "Insert into {$name}", $this->current_theme ),
                'uploaded_to_this_item'    => esc_html__( "Uploaded to this {$name}", $this->current_theme ),
                'featured_image'           => esc_html__( 'Featured image', $this->current_theme ),
                'set_featured_image'       => esc_html__( 'Set featured image', $this->current_theme ),
                'remove_featured_image'    => esc_html__( 'Remove featured image', $this->current_theme ),
                'use_featured_image'       => esc_html__( 'Use as featured image', $this->current_theme ),
                'menu_name'                => esc_html__( ucfirst($name), $this->current_theme ),
                'filter_items_list'        => esc_html__( "Filter {$plural_name} list", $this->current_theme ),
                'filter_by_date'           => esc_html__( '', $this->current_theme ),
                'items_list_navigation'    => esc_html__( ucfirst($plural_name). " list navigation", $this->current_theme ),
                'items_list'               => esc_html__( ucfirst($plural_name). " list", $this->current_theme ),
                'item_published'           => esc_html__( ucfirst($name). " published", $this->current_theme ),
                'item_published_privately' => esc_html__( ucfirst($name). " published privately", $this->current_theme ),
                'item_reverted_to_draft'   => esc_html__( ucfirst($name). " reverted to draft", $this->current_theme ),
                'item_scheduled'           => esc_html__( ucfirst($name). " scheduled", $this->current_theme ),
                'item_updated'             => esc_html__( ucfirst($name). " updated", $this->current_theme ),
                'text_domain'              => esc_html__( 'pn-origami', $this->current_theme ),
            ];
            $args = [
                'label'               => esc_html__( ucfirst($plural_name) ,  ),
                'labels'              => $labels,
                'description'         => '',
                'public'              => true,
                'hierarchical'        => false,
                'exclude_from_search' => false,
                'publicly_queryable'  => true,
                'show_ui'             => true,
                'show_in_nav_menus'   => true,
                'show_in_admin_bar'   => true,
                'show_in_rest'        => true,
                'query_var'           => true,
                'can_export'          => true,
                'delete_with_user'    => true,
                'has_archive'         => false,
                'rewrite'             => true,
                'rest_base'           => '',
                'show_in_menu'        => 'vertical',
                'capability_type'     => 'page',
                'supports'            => ['title', 'editor', 'thumbnail', 'author', 'excerpt', 'custom-fields', 'trackbacks', 'revisions', 'comments', 'page-attributes', 'post-formats'],
                'taxonomies'          => ['category'],
            ];
            register_post_type( $name, $args );
        
        endforeach;
    }

我不确定有什么问题以及为什么我不能像普通帖子一样使用任何具有自定义帖子类型的插件。

谢谢

标签: wordpressadminmeta-boxes

解决方案


推荐阅读