Removing Portfolio breaks sidebars

Hello there,

We have removed the Portfolio feature with the following snippet:

function nh_pro_cleanup(){
    unregister_post_type( 'x-portfolio' );
    unregister_taxonomy( 'portfolio-tag' );
    unregister_taxonomy( 'portfolio-category' );
}
add_action('init','nh_pro_cleanup', 9999);

Unfortunately, this has the result of breaking the Sidebars “All Taxonomies” list in “Appearance > Sidebars”.

When this snippet is active, the taxonomies list is empty.

Is there a better way to remove the portfolio to avoid this behavior?

Thank you!

Hello @thisisbbc,

Thanks for writing in!

To resolve this issue, please have your code updated and use this code instead:

function delete_post_type() {
  unregister_post_type( 'x-portfolio' );
  unregister_taxonomy_for_object_type( 'portfolio-tag', 'x-portfolio' );
  unregister_taxonomy_for_object_type( 'portfolio-category', 'x-portfolio' );
}
add_action('init','delete_post_type', 9999);

Kindly let us know if this works out for you.

Worked like a charm!

Thanks @RueNel

You’re most welcome!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.