title: Unregister custom post type from Wordpress
body: <p>I'm trying to remove a custom post type that was set via a different theme in Wordpress, now all of those posts are assigned to a <code>post_type</code> of <code>portfolio</code>. After a lot of searching, I found the code below, however it doesn't seem to work. I tried adding it both to the new theme and the old themes <code>functions.php</code>.</p>
  
  <p>I want to remove the post_type and have the posts categorized and displayed as a normal post. I think what I'm doing is correct, but can't seem to get it to work - I've posted both the code for the custom post type and the code to unregister the posts assigned to it.</p>
  
  <p>Code to uregister post type</p>
  
  <pre><code>if ( ! function_exists( 'unregister_post_type' ) ) :
  function unregister_post_type() {
  global $wp_post_types;
  if ( isset( $wp_post_types[ 'portfolio' ] ) ) {
      unset( $wp_post_types[ 'portfolio' ] );
      return true;
  }
  return false;
  }
  endif;
  
  add_action('init', 'unregister_post_type');
  </code></pre>
  
  <p>Code that registered the post type</p>
  
  <pre><code>register_post_type( 'portfolio',
      array(
          'labels' =&gt; array(
               'name' =&gt; __('Portfolio Items'),
               'singular_name' =&gt; __('Portfolio Item'),
               'add_new_item' =&gt; __('Add New Portfolio Item'),
               'edit_item' =&gt; __('Edit Portfolio Item'),
               'new_item' =&gt; __('New Portfolio Item'),
               'view_item' =&gt; __('View Portfolio Item'),
               'search_items' =&gt; __('Search Portfolio Items'),
               'not_found' =&gt; __('No portfolio items found'),
               'not_found_in_trash' =&gt; __('No portfolio items found in Trash')
          ),
          'public' =&gt; true,
          'show_ui' =&gt; true,
          'hierarchical' =&gt; false,
          'menu_position' =&gt; 7,
          //'rewrite' =&gt; array('slug' =&gt; 'portfolio'),
          'rewrite' =&gt; true,
          '_built_in' =&gt; false,
          'taxonomies' =&gt; array( 'post_tag','category','portfolio_tag', 'portfolio_category', 'client'),
          'supports' =&gt; array( 'title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions')
      )
  );
  </code></pre>