Do you want to reset all WordPress settings back to default? While there’s probably a plugin for this, we have created a quick code snippet that you can use to reset options back to default with update_option
in WordPress.
Instructions:
All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:
$options = array( array( 'name' => 'thumbnail_size_w', 'value' => '150' ), array( 'name' => 'thumbnail_size_h', 'value' => '150' ), array( 'name' => 'medium_size_w', 'value' => '250' ), array( 'name' => 'medium_size_h', 'value' => '250' ), array( 'name' => 'large_size_w', 'value' => '728' ), array( 'name' => 'large_size_h', 'value' => '728' ), array( 'name' => 'embed_size_w', 'value' => '728' ), array( 'name' => 'embed_size_h', 'value' => '600' ), ); foreach ( $options as $option ) { if ( get_option( $option['name'] ) != $option['value'] ) { update_option( $option['name'], $option['value'] ); } else { $deprecated = ' '; $autoload = 'no'; add_option( $option['name'], $option['value'], $deprecated, $autoload ); } }
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 24 best WordPress multi-purpose themes and how to create a WordPress form with a date picker.
Comments Leave a Reply