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.

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

报告相同问题?

悬赏问题

  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题