Archive for February, 2010

Three things to add to every Wordpress theme function file

// February 23rd, 2010 // No Comments » // tagged: > >

I develop a lot of wordpress sites and always try to customize the site with as few plugins as possible. Many people use plugins for something that can EASILY be done with a few lines of code in your themes functions.php file.

Here are three functions.php edits I use on every single new wordpress install:

Custom Login Screen – 4 lines of code

With three lines of code you can customize your login screen with your logo.  Easy peasy. Upload your logo to your themes directory — change the file name — and wala.  Good to go.

function my_custom_login_logo() {
  echo '<style type="text/css">h1 a { background-image:url('.get_bloginfo('template_directory').'/yourlogo.jpg) !important; }</style>';
   }
add_action('login_head', 'my_custom_login_logo');

Remove wordpress update notice – 5 lines of code

I don’t want my end users seeing the wordpress update notice when they login.  I see it … that’s enough.  I don’t need emails from them telling me about it :)

add_action('admin_menu','bhhidenag');
function bhhidenag()
{
remove_action( 'admin_notices', 'update_nag', 3 );
 }

Remove all those extra links in the header – 9 lines of code (max)

Most of my wordpress sites aren’t blogs … and so I remove a lot of the bloggy links from the header.  You can pick and choose which ones you want to leave.  I never include the generator line because that just announces to the world what version of WP your site is running … “hello hackers, try to exploit me with my known bugs”.  LOL

remove_action( 'wp_head', 'feed_links_extra', 3 ); // extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // WP version