How to delete some of the sample data and CPT's

i would like to lighten the load of stock/example data and de register/delete some of the custom post types that got installed with the sydney-toolbox. how do i get rid of the custom post types like “employees” and “pricing tables” etc. i don’t want to get rid of all of them because i am using a few (“services”) for example. is there a way to get rid of some of them? what is the best way?

  • my solution currently is to comment out some of the code in the sydney-toolbox plugin. this seemed to hide the custom post types. is this the right thing to do, or are there things behind the scenes still running/registering these hidden CPTs?. the only one i couldn’t hide was pricing table? can you advise on that as well.

Hello there,

You could use the below snippets and add it to your child theme’s functions.

    function sydney_child_unset_cpt( $post_type ) {
        global $wp_post_types;
        if ( isset( $wp_post_types[ $post_type ] ) ) {
            unset( $wp_post_types[ $post_type ] );
            return true;
        }
        return false;
    }

    add_action( 'init', 'sydney_child_remove_cpt', 9999 );
    function sydney_child_remove_cpt() {

      // Custom post type slug names
      $cpt_slugs = array('employees', 'clients', 'timeline-events', 'testimonials', 'projects');

      foreach($cpt_slugs as $cpt) {
        sydney_child_unset_cpt($cpt);
      }

    }

If you don’t have an active child theme, alternatively you could use a plugin that allows the same purpose like the Functionality.

CPT that would be removed are defined in the $cpt_slugs array:

$cpt_slugs = array('employees', 'clients', 'timeline-events', 'testimonials', 'projects');

Regards,
Kharis

thanks that works. i guess i can use the database optimize plugin to see if it gets rid of the data? i can’t seem to find where “pricing tables” came from. any idea how i can get rid of that CPT?

Hello there,

For pricing table, use pricing-tables slug name. The code is defined in the theme’s code.

Regards,
Kharis

hmm. i added it to the array but it did not remove it. any other ideas why this might be sticking or how to where to remove from the themes code?

Please your final code here, there might be something I could correct.

Regards,
Kharis

function sydney_child_unset_cpt( $post_type ) {
    global $wp_post_types;
    if ( isset( $wp_post_types[ $post_type ] ) ) {
        unset( $wp_post_types[ $post_type ] );
        return true;
    }
    return false;
}

add_action( 'init', 'sydney_child_remove_cpt', 9999 );
function sydney_child_remove_cpt() {

  // Custom post type slug names
  $cpt_slugs = array('employees', 'clients', 'timeline-events', 'pricing-tables');

  foreach($cpt_slugs as $cpt) {
    sydney_child_unset_cpt($cpt);
  }

}

for now i commented out a few lines in the parent themes function file. that would be a temporary fix for now unless you have a better way. thanks kharis

after that last update the pricing tables are back. is there a way to get rid of these in my function.php file or child theme? the above code does not work for pricing tables. thanks

Hello there,

Try adding this snippet into your child theme’s functions.

if( !function_exists( 'sydney_remove_post_type' ) ) {
    function sydney_remove_post_type(){
        unregister_post_type( 'pricing_tables' );
    }
}
add_action('init','sydney_remove_post_type', 9999);

Regards,
Kharis

yeah - that did it. thanks kharis

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis