• I’ve had some code sitting inside custom_functions.php in my theme (Thesis) however when I add the code into a plugin instead it throws up a rewrite error. I’ve looked through the codex and a few posts but I can’t seem to work out what needs to change. I think it’s something to do with load order but I could be wrong?

    /** Add Tutorials Post Type **/
    add_action('init', 'tutorials_register');
    function tutorials_register() {
        $args = array(
            'label' => __('Tutorials'),
            'singular_label' => __('Tutorial'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', 'revisions')
           );  
    
        register_post_type( 'tutorials' , $args );
    }
    register_taxonomy("training-course", array("tutorials"), array("hierarchical" => true, "label" => "Training Courses", "singular_label" => "Training Course", "rewrite" => true));
    register_taxonomy("tutorial-category", array("tutorials"), array("hierarchical" => true, "label" => "Tutorial Categories", "singular_label" => "Tutorial Category", "rewrite" => true));
    register_taxonomy("experience-level", array("tutorials"), array("hierarchical" => false, "label" => "Experience Levels", "singular_label" => "Experience Level", "rewrite" => true));
    register_taxonomy("estimated-time", array("tutorials"), array("hierarchical" => false, "label" => "Estimated Completion Times", "singular_label" => "Estimated Completion Time", "rewrite" => true));

    The following error message is produced when the code is activated by a plugin instead “Fatal error: Call to a member function add_rewrite_tag() on a non-object in /home/website/public_html/wp-includes/rewrite.php on line 51”

    Also wondering if there is a limit on the taxonomies or if some of these would be better suited to custom fields with built in meta boxes?

Viewing 1 replies (of 1 total)
  • I think register_taxonomy() needs to be done on init so try doing these directly after your register_post_type() function. See if that works…

Viewing 1 replies (of 1 total)
  • The topic ‘Rewrite Error when registering custom post/taxonomy?’ is closed to new replies.