1 CommentOutput which theme template file a post/page is using in the header of WordPress
This is a tip to help developers when creating or editing a WordPress template. This is a dead simple code and is especially useful for big templates (like a magazine style or e-commerce). It will show which template are being currently used by WordPress. add_action(‘wp_head’, ‘show_template’); function show_template() { global $template; print_r($template); }
Read More2 CommentsEnable GZIP output compression on a WordPress Blog
This is a great optimization code for any wordpress blog out there. Some servers might do it automatically, others don’t, in case of doubt just create the code below in the functions.php file and see your bandwidth consumption go down just like your site loading time. if(extension_loaded(“zlib”) && (ini_get(“output_handler”) != “ob_gzhandler”)) add_action(‘wp’, create_function(”, ‘@ob_end_clean();@ini_set(“zlib.output_compression”, 1);’));
Read More3 CommentsHow to Unregister WordPress Default Widgets
Tired of that huge amount of Widgets list cluttering the add/remove widget page? With this piece of code you are going to be able to remove all that unused ones and keep only the ones you might use. // unregister all default WP Widgets function unregister_default_wp_widgets() { unregister_widget(‘WP_Widget_Pages’); unregister_widget(‘WP_Widget_Calendar’); unregister_widget(‘WP_Widget_Archives’); unregister_widget(‘WP_Widget_Links’); unregister_widget(‘WP_Widget_Meta’); unregister_widget(‘WP_Widget_Search’); unregister_widget(‘WP_Widget_Text’); unregister_widget(‘WP_Widget_Categories’); [...]
Read More1 CommentHow to Remove Plugin Update Notice for Inactive plugins in WordPress
This is a very easy code to implement that will make the Admin life easier in a WordPress blog. With this code we are going to remove the notice to update plugins that shows even for the inactive ones. function update_active_plugins($value = ”) { /* The $value array passed in contains the list of plugins [...]
Read More0 CommentHow to Customize WordPress Admin Menu Order
This piece of code allows you to change the position of the elements in the admin menu. All you need to do is click on an existing link in the admin menu and copy everything before the /wp-admin/ URL. In the code below we a new order the admin menu will have: // CUSTOMIZE ADMIN [...]
Read More0 CommentHow To Add Custom WordPress User Profile Fields
Ever wondered how to add that piece of extra information about the users in your WordPress site? Fear no more! Bellow is a very easy code to implement in your functions.php file that will allow you to add any and every type of information you want to save about your users. // CUSTOM USER PROFILE [...]
Read More0 CommentHow to Remove Default WordPress Meta Boxes
Want to get rid of some specific Meta Box in WordPress Admin pages where you add or edit pages and blog posts? Thats actually quite easy, besides the fact that you can do that through the top options panel (Screen Options), you can also do that permanently by using the code below in the functions.php [...]
Read More0 CommentSet a maximum number of post revisions in WordPress and avoid DB bloat.
By default, WordPress will save an infinite amount of versions of each and every post of yours. That means that some posts, heavily edited, can easily reach 10 or more versions. That ends up causing some really unnecessary loading on your blog, to avoid that you can easily limit the number of revisions by adding [...]
Read More0 CommentOptimizing WordPress: Loading jQuery from the Google CDN
In this post you will find out a really underrated optimization for WordPress. This code cancels the jQuery load from the WordPress default install and in exchange will load the jQuery direct from Google CDN, making your site faster and more robust. // even more smart jquery inclusion add_action( ‘init’, ‘jquery_register’ ); // register from [...]
Read More2 CommentsInclude custom post types in the WordPress Search Results
Below is a must do code for anyone working with custom post types in wordpress. It includes those custom post types in the search results of WordPress. // MAKE CUSTOM POST TYPES SEARCHABLE function searchAll( $query ) { if ( $query->is_search ) { $query->set( ‘post_type’, array( ‘site’, ‘plugin’, ‘theme’, ‘person’ )); } return $query; } [...]
Read More