簡體   English   中英

WordPress自定義帖子類型將我重定向到帖子

[英]Wordpress custom post type redirects me to posts

如果我在自定義帖子類型編輯頁面上,然后單擊菜單中的“編輯出版物”或“創建”鏈接,我總是會重定向到常規文章頁面!

$labels = array(
            'name'               => 'Edit Publications',
            'singular_name'      => 'Edit Publications',
            'edit_item'          => 'Edit Publications'
        );
        $args = array(
            'labels'            => $labels,
            'public'            => true,
            'publicly_queryable'=> true,
            'show_ui'           => true,
            'show_in_nav'       => true,
            'query_var'         => true,
            'map_meta_cap'      => true,
            'hierarchical'      => false,
            'supports'          => array(''),
            'has_archive'       => true,
            'rewrite'           => array('slug' => 'publication')
        );

如果我是第一次進入wp-admin頁面,或者我當前未編輯任何帖子,則該URL不同並且可以正常工作

例如,當前我在儀表板頁面上,指向“編輯出版物”的鏈接為

http://example.com/wp-admin/edit.php?post_type=mfl_publication

如果我在自定義帖子類型編輯頁面上,則指向“編輯出版物”的鏈接為

http://example.com/wp-admin/post.php/edit.php?post_type=mfl_publication

我不知道為什么謝謝

嘗試這個

function create_example()
{
    register_taxonomy_for_object_type('category', 'example'); // Register Taxonomies for Category
    register_taxonomy_for_object_type('post_tag', 'example');
    register_post_type('example', // Register Custom Post Type
        array(
            'labels' => array(
                'name' => __('example', 'example'), // Rename these to suit
                'singular_name' => __('Comunicado', 'example'),
                'add_new' => __('Add New', 'example'),
                'add_new_item' => __('Add New Comunicado', 'example'),
                'edit' => __('Edit', 'example'),
                'edit_item' => __('Edit Comunicado', 'example'),
                'new_item' => __('New Comunicado', 'example'),
                'view' => __('View Comunicado', 'example'),
                'view_item' => __('View Comunicado', 'example'),
                'search_items' => __('Search Comunicado', 'example'),
                'not_found' => __('Nothing Found', 'example'),
                'not_found_in_trash' => __('Nothing Found in Trash', 'example')
            ),
            'public' => true,
            'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
            'has_archive' => true,
            'supports' => array(
                'title',
                'thumbnail'
            ), // Go to Dashboard Custom HTML5 Blank post for supports
            'can_export' => true, // Allows export in Tools > Export
            'taxonomies'  => array( 'category' )
        ));
}


add_action('init', 'create_example'); // Add our HTML5 Blank Custom Post Type

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM