24 WordPress Tweaks



I will share my most useful 24 WordPress Tweaks that I have used for most my web development. I have gathered these codes from
everywhere but I cannot remember which is where and had made revisions so it works for me. Below is a list of
24 WordPress Tweaks that i hope you will find it useful.

Admin Tweaks

1. Disable the admin bar for all users except administrator

Add the following code to your themes/theme-name/functions.php.

add_action('after_setup_theme', 'hide_adminbar');
function hide_adminbar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}

2. Add a custom logo to admin bar

Add the following code to your themes/theme-name/functions.php and upload the logo then change the location of the logo after template_directory.

add_action('admin_head', 'dashboard_logo');

function dashboard_logo() {
echo '

';
}

3. Switch off notifications from dashboard

Add the following code to your themes/theme-name/functions.php.

function remove_dashboard_meta() {
        remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_primary', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_secondary', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
        remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
        remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
        remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
}
add_action( 'admin_init', 'remove_dashboard_meta' );

4. Turn off WordPress Update Message

Add the following code to your themes/theme-name/functions.php.

add_action('admin_head','admin_css');
function admin_css()
{
if(!current_user_can('administrator'))
{
    echo '';
    }
}

5. Hide dashboard panel WordPress logo

Add the following code to your themes/theme-name/functions.php.

function no_wp_logo_admin_bar_remove() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'no_wp_logo_admin_bar_remove', 0);

6. Remove Help Tab in dashboard

Add the following code to your themes/theme-name/functions.php.

add_action('admin_head', 'help_tab');
function remove_help_tab() {
    $screen = get_current_screen();
    $screen->help_tabs();
}

Theme tweaks

7. Change the default WordPress email from

Open the file in /wp-includes/pluggable.php then replace the ‘WordPress’ name and sitename “wordpress@ to your own.

$from_name = 'WordPress';

$from_email = 'wordpress@' . $sitename;

8. Custom login logo

Add the following code to your themes/theme-name/functions.php .

function my_login_logo() {
	echo '';
}
add_action('login_head', 'my_login_logo');

9. Redirect to homepage after log out

Add the following code to your themes/theme-name/functions.php .

function go_home(){
  wp_redirect( home_url() );
  exit();
}

10. Open all External links in a new tab

Add the following code to your themes/theme-name/functions.php and change http://your.url.com to the url you have WordPress installed

   function autoblank($text) {
    $myurl = 'http://your.url.com';
    $external = str_replace('href=', 'target="_blank" href=', $text);
    $external = str_replace('target="_blank" href="'.$myurl, 'href="'.$myurl, $external);
    $external = str_replace('target="_blank" href="#', 'href="#', $external);
    $external = str_replace(' target = "_blank">', '>', $external);
    return $external;
    }
    add_filter('the_content', 'autoblank');
	add_action('wp_logout','go_home');

11. Custom excerpt length

Add the following code to your themes/theme-name/functions.php

	function custom_excerpt_length( $length ) {
		return 50;
	}
	add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

12. Change the default excerpt […]

Add the following code to your themes/theme-name/functions.php

 function new_excerpt_more( $more ) {
		return '';
	}
	add_filter('excerpt_more', 'new_excerpt_more');

Security Tweaks

13. Deleting Readme.html

Hide your WordPress version by deleting readme.html in WordPress main folder.

14. Disable File Editing

Add the following code to your wp-config.php.

define('DISALLOW_FILE_EDIT', true);

15. Disallow wp-config access by surfers

Add the following code to the very top of your .htaccess


order allow,deny
deny from all

17. Removing version from header

remove_action('wp_head', 'wp_generator');

18. Hide WordPress version number from RSS feeds

Add the following code to your themes/theme-name/functions.php.

function hide_wp_version_rss() {
 return'';
 }
	 
add_filter('the_generator','hide_wp_version_rss');

19. Remove RSD Links from header

Only if you not using RSD Links to edit your blog contents then you can remove it. Add the following code to your themes/theme-name/functions.php.

remove_action( 'wp_head', 'rsd_link' ) ;

20. Remove Windows Live Writer link from header

Same as above remove Windows Live Writer if you not using it to edit blog client. Add the following code to your themes/theme-name/functions.php.

 
remove_action( 'wp_head', 'wlwmanifest_link' ) ;

21. Hide url in comment form

Add the following code to your themes/theme-name/functions.php.

add_filter('comment_form_default_fields', 'url_hide');
function url_hide($fields)
{
  if(isset($fields['url']))
   unset($fields['url']);
  return $fields;
}

Performance Optimization

22. Limit WordPress Post Revisions

Add the following code to your wp-config.php. By default WordPress saves unlimited revision copies in your database.
You can change the number after WP_POST_REVISIONS.

define( 'WP_POST_REVISIONS', 3 ); 

Enable Gzip compressor

Load your pages 70% quicker by adding to your .htaccess to enable Gzip compression.

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png 

24. Prevent Google from crawling your core files

Add the following to robot.txt that is in the main folder.

User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/themes/
Disallow: /wp-content/plugins/

Further readings go to :
http://codex.wordpress.org


Leave a Reply

You must be logged in to post a comment.