Switching themes without losing widgets?

Storing widgets is complex topic. Basically it is such a multi-level-array-mess on the inside that very few people try to make sense of it (and even fewer succeed). 🙂 As far as I understand it myself while we can manipulate cute sidebar names on the surface, deep inside it is getting deconstructed to numerical IDs. … Read more

Categorising themes by folders in backend

Updated plugin version available at GitHub. I first saw your Question at [wp-hackers] list, and, after implementing the solution, was about to publish a Q&A for that. Well, it’s already here, and has a bounty put on it 🙂 As Daniel Bachhuber points out in the thread: WordPress.com puts themes inside of subdirectories /wp-content/themes/public /wp-content/themes/premium … Read more

How to create a new theme from scratch?

An alternative to a “skinnable” theme framework like Carrington (which indeed is awesome) is to integrate a design you’ve done from scratch. This is how I learned how to create custom WordPress themes. Note: this is a hacky method that involves lots of experimentation. But if you’re like me, and learn best when you’re playing … Read more

Best practices for a Style/CSS based theme options page?

creating a custom script that writes to the static CSS file is a bad idea!!! you would need to regenerate the file each time you save any changes. a better solution would be to save all options in an array of options say for example: $MyCSS[‘background_color’] = #009988; $MyCSS[‘background_repeat’] = no-repeat; update_option(‘theme_settings’,$MyCSS); and that why … Read more

When cropping a header image, retain meta data (i.e. name, description, etc.) from original image?

Here’s one idea, that might need further testing: /** * Cropped header image with the same description/caption as the original image */ add_filter( ‘wp_create_file_in_uploads’, function( $cropped, $attachment_id ) { add_filter( ‘wp_insert_attachment_data’, function( $data ) use ( $attachment_id) { if( doing_action( ‘wp_ajax_custom-header-crop’ ) && is_array( $data ) ) { // Copy the original description to the … Read more

How do I white label my self-hosted site created by wordpress?

Here is the code I always use whenever I setup a new wordpress blog: CUSTOM ADMIN FOOTER TEXT // CUSTOMIZE ADMIN FOOTER TEXT function custom_admin_footer() { echo ‘<a href=”http://www.netconstructor.com/”>Website Design by NetConstructor, Inc.</a>’; } add_filter(‘admin_footer_text’, ‘custom_admin_footer’); REMOVE VERSION INFO FROM THE HEAD OF FEEDS // REMOVE VERSION INFO FROM THE HEAD OF FEEDS function complete_version_removal() … Read more

“Unexpected error” on update requests

Navigating WP admin in general tends to trigger multiple external requests, such as fetching news feeds and theme/plugin updates (not counting whatever plugin/themes might be doing on their own). You can put configuration constants into wp-config.php to block external requests completely/partially: define( ‘WP_HTTP_BLOCK_EXTERNAL’, true ); define( ‘WP_ACCESSIBLE_HOSTS’, ‘api.wordpress.org,*.github.com’ ); Or configure external requests to use … Read more

How do I add support to my theme for custom menus?

The easiest way is to use the register_nav_menus function.This should be hooked into ‘after_setup_theme’: function my_cool_menu_function(){ register_nav_menus( array( ‘primary’ => ‘Primary Navigation’ )); } add_action( ‘after_setup_theme’, ‘my_cool_menu_function’ ); Then, in your theme, simply call that menu’s position: wp_nav_menu( array( ‘theme_location’ => ‘primary’ ) );