Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to register a CPT from a plugin upon activation but seem to have hit a wall... Anyone see anything im missing? I don't get any errors but the CPT doesn't show up in the dashboard links....

    function ctg_cpt_init() {
    register_post_type( 'ctg_questions',
        array(
            'labels' => array(
                'name' => __( 'Questions' ),
                'singular_name' => __( 'Question' )
                ),
        'public' => true,
        'has_archive' => true,
        'rewrite' => array( 'slug' => 'questions' )
        )
    );
}
add_action( 'init', 'ctg_cpt_init' );

function ctg_rewrite_flush() {
    ctg_cpt_init();
    flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'ctg_rewrite_flush' );

Thanks,

share|improve this question
    
I tried your code and the CPT showed up in the Administration Panels primary navigation menu. Do you mean that you're trying to get it to show up in the 'Right Now' meta box on the dashboard? –  Ian Dunn Jul 12 '11 at 17:44
    
Now she's working for me too! I changed the function namespaces before posting here - must've had a keying error. Thanks for everyones help and appologies for the time waster... –  Peter Gibbons Jul 12 '11 at 18:03

1 Answer 1

up vote 0 down vote accepted

Pull the CPT registration functionality out of the Plugin activation hook, so that it can fire at init, where you want it to.

The Plugin activation hook is a one-time only hook; you need your CPT to fire every time at the init hook, not just once.

share|improve this answer
    
He's calling register_post_type() inside a hook to 'init'. He's only flushing the rewrite rules during the register_activation_hook(). –  Ian Dunn Jul 12 '11 at 17:41
    
Thanks for your answer Chip, appreciated. –  Peter Gibbons Jul 12 '11 at 18:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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