0

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 a author's robot plugin, unfortunately the single page is not found and shows error 404!! My custom post type in the class is as follows:

<?php
/*------------------------
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 publish a post, custom post type single page not found?? but it works when I manually update it again!

0

I was able to solve the problem with my reviews. I put the following code into a query.class.php file and the problem was resolved.

static function init(){
    if (!is_blog_admin()) {
        add_action('parse_query', array(__CLASS__, 'parse_query'));
    }
}

static function parse_query($query) {
    if(!is_blog_admin() && ($query->get('post_type') == 'iwj_job' || is_tax(iwj_get_job_taxonomies())) && $query->is_main_query()) {
    $query->set( 'post_type', array( 'post', 'iwj_job' ) );
    }           
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.