1

Is it possible to "deactivate" a custom post type and then later if you feel like using it again you can simple "activate" it again?

1

Yes, custom post types are registered on the fly, on every request. So you can create an option, say active_custom_post_types and check for that before you register the post type.

Pseudo-code:

$possible_cpts = array( 'book', 'portfolio' );
$active_cpts   = get_option( 'active_custom_post_types' );

if ( ! empty ( $active_cpts ) && is_array( $active_cpts ) )
{
    foreach ( $active_cpts as $cpt )
    {
         if ( in_array( $cpt, $possible_cpts ) )
            register_post_type( $cpt, get_args_from_somewhere() );
    }
}

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.