Wordpress Tips & Tricks E01

WordPress Tips & Tricks Series – Part 01

Hello everyone, welcome you to the KDJ Guru blog. This post is about WordPress which is the most popular content management system in the world. Maybe you are an experienced WordPress developer, newbie or someone who is going to make a website using WordPress. Whoever you are, this post series will be very helpful for you to save your time, save your money, increase the speed of the website, decrease more treats form other parties and much more…

Let’s see what I have today,

  1. Remove Your WordPress Version Number.

As a WordPress site owner/developer, you must always update your WordPress website to the latest version. Sometimes, you may able to be forgotten that thing. If it is, most of the hackers will try to get an advantage from bugs of the previous versions.

However, if you need to hide your version number from WordPress, this is the code you must include in the functions.php file. (Appearance –>Theme Editor).

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

2. Add Customized CSS File.

Sometimes, you may need to have a custom CSS file to style your theme in your way without changing original theme files. for adding a custom CSS file you must make a file called custom.css in the root directory of your theme (wp-content/themes/theme_name/custom.css) and paste the following code into the functions.php file. Then you will able to write your own CSS styles to make your theme better.

function custom_style_sheet() {
wp_enqueue_style( 'custom-styling', get_stylesheet_directory_uri() . '/custom.css' );
}
add_action('wp_enqueue_scripts', 'custom_style_sheet');

3. Add a Custom Logo for WordPress Dashboard

Back-End is designed with WordPress designs. But this way to replace the logo on the WordPress dashboard. following is the code which you must paste into functions.php.

Before that, you must upload a custom logo for your images directory and make sure it is 16×16 pixels. If it’s on the right location you can try the following code now.

functionwpb_custom_logo() {echo'<style type="text/css">#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {background-image: url(' . get_bloginfo('stylesheet_directory') . '/images/custom-logo.png) !important;background-position: 0 0;color:rgba(0, 0, 0, 0);}#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {background-position: 0 0;}</style>';}//hook into the administrative header outputadd_action('wp_before_admin_bar_render', 'wpb_custom_logo');

4. Change Background Color Randomly

If you need to show a different background color on each page load, this is the method which you can use.

You must add the following code lines to functions.php of your theme.

functionwpb_bg() { $rand= array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');$color='#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];echo$color;}

After that, you must edit the header.php file. first, start with finding the <body> tag and replace it with the following code. Then you will see the output in action.

<body <?php body_class(); ?> style="background-color:<?php wpb_bg();?>">>

5. Hiding Login Errors in WordPress

Hiding logo errors in WordPress will help you to secure your website from hackers. If login errors are enabled, we can get what is wrong or not. As we do, hackers also can guess something with those errors. By the way, disabling login errors is not an essential option. But, following is the code on functions.php which you can use to hide login errors. After that, you will see a common error which is hard to guess the wrong one is whether password or username.

functionno_wordpress_errors(){return'Something is wrong!';}add_filter( 'login_errors', 'no_wordpress_errors')

This is the end of this article. I hope you could get something from this article. However, I will continue this series with updated and working tricks. Keep in touch with KDJ Guru (www.kdjguru.com).

Leave a Comment

Your email address will not be published. Required fields are marked *