自定义Post类型,single-(Post - Type}.php


Custom Post Type, the single-(post-type}.php

所以我觉得我在做一些显然很简单的事情,但不知道是什么!我创建了自定义的post type = Author然后创建了single-Author.php来显示每个作者的信息但是当我打开每个作者的link 404.php

这里是自定义的帖子类型author

function p2p2_register_author(){
    $labels = array(
        'name'               => _x( 'همکاران', 'Author' ),
        'singular_name'      => _x('همکار','Author'),
        'add_new'            => _x( 'افزودن همکار', '' ),
        'add_new_item'       => __( 'افزودن همکاران جدید' ),
        'edit_item'          => __( 'ویرایش همکار' ),
        'new_item'           => __( 'همکار جدید' ),
        'all_items'          => __( 'همه همکاران' ),
        'search_items'       => __( 'جست و جو همکار' ),
        'not_found'          => __( 'همکاری یافت نشد' ),
        'not_found_in_trash' => __( 'همکار در زباله دان یافت نشد' ),
        'parent_item_colon'  => '',
        'menu_name'          => 'همکار'
    );
    register_post_type(
        'Author',
        array (
            'labels'             => $labels,
            'description'   => 'ذخیره اطلاعات مربوط به همکاران',
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'query_var'          => true,
            'rewrite'            => array( 'slug' => 'author' ),
            'capability_type'    => 'post',
            'has_archive'        => true,
            'hierarchical'       => false,
            'menu_position'      => null,
            'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
        )
    );
}
        add_action('init', 'p2p2_register_author');
        flush_rewrite_rules();

我也有archive-author,它工作得很好,但single-Author.php不起作用。

任何帮助将非常感激!

访问永久链接页,然后刷新它。我的意思是按下Save Changes按钮。希望你的问题能解决。如果不是,然后将'has_archive' => true,更改为'has_archive' => false,,然后再次点击永久链接页面上的Save Changes按钮。