找不到自定义帖子类型的单页

问题描述 投票:0回答:1

我使用具有自定义帖子类型的插件,当我发布帖子时,它显示在单个页面上,但是当使用作者的机器人插件自动发布该帖子时,不幸的是找不到该页面,并显示错误404! !

//------------------------
//function init
//-------------------------
    static function init(){
        add_action( 'init', array( __CLASS__, 'register_post_types' ) );
    }
//------------------------
//register post type
//-------------------------
 static function register_post_types(){
    $labels = array(
         //custom post type
    );
    $args = array(
            'labels'            => $labels,
            'public'            => true,
            'show_ui'           => true,
            'hierarchical'      => false,
            'rewrite'           => array('slug' => 'jobtest'),
            'query_var'         => true,
            'has_archive'       => true,
            'supports'          => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
    );
    register_post_type( 'iwj_job' , $args );
}

我有具有此功能的主插件文件:

public function init_hooks() {
     register_activation_hook( __FILE__, array( 'IWJ_active', 'activate' ) );
}

然后在我的课堂上,我有这个:

   static function activate() {
     IWJ_Post_Types::register_post_types();
     flush_rewrite_rules();
   }

我不知道为什么当我使用Author Robot插件发布帖子时,找不到自定义帖子类型的单页??但是当我再次手动更新它时,它可以工作!

php wordpress custom-post-type
1个回答
0
投票

用于修复自定义帖子,请在您的functions.php中使用以下代码:

flush_rewrite_rules( false );
而且只需转到设置>永久链接,然后选择一个永久链接结构即可。完成后,单击“保存更改”,并在提示时对.htaccess进行任何更改。现在,再次查看您的自定义帖子,一切都应该与世界同步。
© www.soinside.com 2019 - 2024. All rights reserved.