Please have look on the below code block-
$args = array(
"hide_empty" => 0,
"type" => "post",
"orderby" => "name",
"order" => "ASC"
);
$types = get_categories($args);
foreach ( $types as $type) {
wp_delete_category( $type->ID );
}
The function wp_delete_category
will delete a single category. So we need to run a loop through $types
to delete each single category.
Hope that helps.
Related Posts:
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- How to Loop Plugin Option Field Set?
- Update Multiple Post Meta for the Same Post In One call?
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- WordPress widget / plugin….fields not appearing in my widget
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to list the Hooks and order of execution in current loading page? [duplicate]
- How to Create a Directory in a Plugin Folder?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Create plugin that works in background
- Checking for user role in a custom plugin
- Custom Shipping method not showing in checkout
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Getting media library popup in custom plugin admin page
- jQuery function didn’t work in my plugin
- Escape when echoed
- Write to / remove from default .htaccess file from plugin?
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- How can I get WordPress to save comments in markdown format?
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Redirecting to home page after login as custom role WordPress
- How would I go about creating a user ranked post popularity page?
- Redirection of users away from wp-admin (but not administrators)
- code is working properly in Core PHP but writing coding in WordPress
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery
- Redirect to another page using contact form 7? [closed]
- Create a plugin from within WordPress
- Class variables not correct on page
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- Activate my plugins via FTP
- Duplicate results are displayed in a custom plugin [closed]
- Why is my custom post type not being activated on plug-in activation?
- How to add apply_filter for a class property in plugin
- How to redirect to same page after form submission
- A server-side hook failed when committing plugin code to SVN
- Content-Security-Policy Headers are there and showing the correct settings, but still getting a refused connection
- How do I add $_SESSION[”] to my wordpress page?
- I receive taxonomy id
- output html on post or page from custom plugin [closed]
- Loop in elementor custom widget not working
- Built a second plugin but it overwrote the first one
- Creating a functionality plugin to edit seriously simple podcasting
- Asynchronous request in wordpress
- How to use custom Javascript code inside a plugin?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- Way to send multiple values for column to MySQL?
- Using meta_query in a WP_Query not working for numbers properly
- How to write to a separate PHP file in plugin settings
- Create “new pages” within the admin section of plugin
- How to display results from a data table with an encrypted user id?
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- Conditional delete metadata does not works
- admin_notices show after load completed
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- Why is my shortcode not working?
- Rename a folder via HTML POST request
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- working code, not working – Plugin Dev
- WordPress plugin blog creation
- implement checkbox or toggle switch in plugin code
- 500 Internal server error wp_handle_upload_prefilter
- Create a form and have custom menu display based on user answers?
- Can’t access 3rd party API, code works on local server but not on wordpress
- Get post content inside plugin class method
- submit form data to wordpress existing database table using my plugin
- register_activation_hook doesn’t fire at all
- My ajax request don´t work and return 0
- Problem with conditional woocommerce custom checkout field
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Saving plugin data returns “You do not have sufficient permissions to access this page.”
- Plugin Breaking WordPress Login
- How to add a handler for a button in plugin?
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Load my plugin before cache
- How to fix ‘Call to undefined function do_settings()’ error?
- What is the source outline for a basic word press plugin?
- Submit posts in two different post types with the same form
- wordpress select multiple options and illegal string offset ‘timeslot’ [closed]
- how to search through plugin in wordpress cimy-user-extra-fields?
- Displaying Category Feature image on loop
- Accessing Correct Database to Create REST API Endpoint