douweng1935 2016-08-20 08:24
浏览 8
已采纳

自定义帖子类型,单一(后置型).php

So I feel like I am doing something obviously simple, yet can't figure out what! I created my custom post type = Author and then created single-Author.php to display the information of each author but when I open link of each author 404.php

here is custom post type 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();

I also have archive-author and it works really fine but single-Author.php doesn't work.

Any help would be much appreciated!

  • 写回答

1条回答 默认 最新

  • dongzhen6554 2016-08-20 08:35
    关注

    Visit the permalink page, then flush it. I mean hit Save Changes button. Hope your problem is gonna fixed. If it is not then change 'has_archive' => true, to 'has_archive' => false, then again hit Save Changes button on permalinks page. Your problem will be fixed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!