0
votes

I use a plugin that has a custom post type and when I publish a post it is displayed on a single page but when the post is automatically published using an author's robot plugin, unfortunately, the single page is not found and shows error 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 );
}

I have the main plugin file with this function:

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

Then within my class, I have this:

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

I don't know why when I use the Author Robot Plugin for publishing a post, custom post type single page not found?? but it works when I manually update it again!

1

1 Answers

0
votes

For fixing custom post not found please use below code in your functions.php:

flush_rewrite_rules( false );

And, Simply go to settings>permalinks and choose a permalink structure if you haven’t done so already. Once done click “save changes” and make any changes to .htaccess if prompted to do so. Now view you custom post again and all should be right with the world.