Update WordPress settings and options

/**
 * @since version 1.1
 *
 * On theme activation, add initial settings. 
 *
 */
function wpsnippit_initialize_parent() {

   //check if your theme settings exist first
   if( get_option( 'wpsnippit_theme_settings' ) == '' ) { 

      /** 
       * @since version 1.2 - set wordpress defaults
       * 
       * update permalink structure to /post-name/
       * set ping status (closed)
       * set discussion status (closed)
       * set comment_registration to '1' - Users must be registered and logged in to comment
       * set comment_moderation to '1' - Comment approval must be manual
       * remove default image linking - this is an awesome fix for noobs!
       * enable gzip - handy for browsers that support it
       * remove comment notifications
       */

       //update permalink to /post-name
       update_option('permalink_structure', '/%postname%/'); 

       //update default ping status to closed
       update_option('default_ping_status', 'closed');

       //update default discussion status to closed
       update_option('default_comment_status', 'closed');

       //Users must be registered and logged in to comment
       update_option('comment_registration', '1'); 

       //Comment must be manually approved
       update_option('comment_moderation', '1'); 

       //Turn off automatic image linking                
       update_option('image_default_link_type', 'none');

       //enable gzip
       update_option('gzipcompression', '1');

       //dont email me EVERY time a comment is posted
       update_option('comments_notify', '1');

}
add_action('after_setup_theme', 'wpsnippit_initialize_parent' ); //hook into after_setup_theme

Add this to your child theme’s functions.php file. Hooked into WordPress makes this little wpsnipp.it even more handy. When your theme is installed, the code will run and update ALL of these options. Sure beats going through Settings and editing the options manually.

«