How to add DNS Prefetch in a WordPress Theme without using Plugin

Go to Google, search for any keyword, hold two seconds and then click the first link, that site will open instantly on your browser without showing you any loading progress.  That is called DNS Preftech.

Google defines it as:

DNS prefetching is an attempt to resolve domain names before a user tries to follow a link. This is done using the computer’s normal DNS resolution mechanism; no connection to Google is used.

So, basically what is happening is that your browser downloads and saves the URL in its buffer and as soon as you click that link it shows you the page from its buffer rather than pulling it from the server. As a developer you cannot know which link your user might click but on certain pages you can anticipate which link a user might click.

For an example, on a blog archive page – a user might click the first news whereas on the single post/page a user might click the home link or the logo to visit the homepage on your site. So, you can add DNS Prefetching for these links based on what you think your user might click next.  You can use the following code snippet and and paste it your theme’s functions.php to enable DNS Prefetching in single post .

if( ! function_exists( 'wphelp_dns_prefetch' ) ) :

	function wphelp_dns_prefetch(){
		if ( is_singular() ) { 
                  echo '<link rel="prefetch" href="' .esc_url( home_url() ) . '">';				
                   echo '<link rel="prerender" href="' .esc_url( home_url() ) . '">';				



add_action('wp_head', 'wphelp_dns_prefetch');

This snippet will enable DNS Prefetching on single post, so when a user is on single post or page or any custom post type and clicks on the link for homepage then the homepage will open without any delay.

Note: DNS Prefetching only works with HTTP2. So if your server does not supports HTTP2 then this will not work.

How to Remove WordPress Dashboard Widgets

Working on a recent project, a client asked me to clean up all the widgets that shown on default WordPress Dashboard as soon as you login. They were not using any of those widgets so wanted to see a clean dashboard upon logging in.

Removing default Dashboard Widgets is easy by adding few lines of codes into your theme’s functions.php file.

Copy the following code and paste it in your 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', 'side' );
        remove_meta_box( 'dashboard_secondary', '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' );
        remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');//since 3.8
add_action( 'admin_init', 'remove_dashboard_meta' );


How to display all custom fields (name AND value) in a post?

You are working on a custom WordPress theme that uses lots and lots of custom fields and you suddenly want to see what all custom fields are assigned to any post.  You can do by going into the dashboard of the site and editing the specific post but what if you want to show it on the front-end of site on the single post template?

What if you have tons of custom fields and just want to show them all on the single post without specifying specific custom field name/key?

In that case you can use the snippet below inside the post loop to show all the custom fields that are attached to a post:

$custom_fields = get_post_custom();

foreach ( $custom_fields as $field_key => $field_values ) {
	foreach ( $field_values as $key => $value )
		echo $field_key . ' - ' . $value . '<br />';


How to enable gZip Compression in WordPress without using any Plugin?

There is nothing new in the Gzip compression rather it is similar to zip compression that we perform in our local hard disk to compress the information so that the size of the page would be reduced with certain limit. This operation will be performed in the web server that helps the site to load faster without any complication as compare to other site with same set of features. Gzip will help to minimize the size of the file with maximum of seventy percentage of the original document which means it take less number of time to load the data in quick session with lesser number of bandwidth. The current generation site are been working with gzip compression that features the huge in efficient manner.

Benefits Of Gzip Compression In WordPress

When you search for the information in the WordPress file will take less number of times to search and give you the accurate information rather appropriate data. Another feature is the server will take less space to process the request with high range of time consuming. For example, in simple term if the actual size of the file is ten thousand kb then it will be shrinking to thousand kb and make your work easy.

Process In Online Gzip Compression
1. Start the process via online
2. Request process to server for content using browser
3. Condition applies

If yes, then server will give permission to read the page and the loading process will be much faster. If no, the page will load slower

As the day progress, there are various strategy has been introduced in order to access the gzip compression in efficient manner in WordPress services. This will improve the performance of the site in all aspect. Most of the people would like to make use of the plugin like W3 total cache, W3 super cache and soon in order to make their process much faster. But if you want to improve the performance without the plugin usage and this gzip compression can also be used in other tools other than WordPress too.

Procedure For Gzip Compression With WordPress

The process to enable the Gzip compression on the WordPress is very simple which you need to know the how to handle and edit the file called as .htaccess that would appear at the root directory of the WordPress site. In this current generation most of the experience users are making use of FileZilla and download the .htaccess file through the text editor. Just the update the below code in the .htaccess file and re-upload it back in the hosting account too.

AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript

If you feel uneasy to make use of code then you can go with below post in order to find the solution.
Just process the Gmetrix page in order to check the speed of the Gzip compression to the .htaccess file and check the difference between the two and then proceed further improve the performance.

How to Embed PDFs in a WordPress Page?

Embedding the pdf file in the WordPress page or post is simple and safe. There are various features available in the WordPress in order to embed the pdf file in the page. One of the major thing is in the current version of the WordPress is inbuilt the plugin that need to be activated so that you can easily attach the files like pdf directly inside the page. Similar to the image storage in the page of the WordPress document, you need to follow the same process that is just store the pdf file and then follow the below steps:

  • Open the WordPress dashboard
  • Click on the “Media” Option.
  • And then go with “Add New”.
  • Select the file from the local disc and update it.
  • Copy the path of the pdf file.
  • Paste it in the page in which it is required.

This is one of the normal procedures in order to embed the pdf file in the WordPress . The same process has been implementing the post too. In some cases there may be an option to not visible of the pdf file information in the media library. At that time, you need to customize the option in order to upload the pdf file in it. Use the tag like [pdf]…[/pdf]. There are various parameters are available in the pdf shortag like title, width and height.

Compatibility Of PDF File In WordPress

In general pdf setup used to be horizontal alignment and it supports in most of the browser but in some cases there may be some issue causes because of incompatibility. For example, most of the wordpress user would have experienced such kind of issue that is loading an image in the site would work fine but when you talk about the pdf, maximum number of people would face some problem. Due to some security issue, there may have a chance of viewing the page with blank with grey background. In some other cases, you have only option to click and download the file to view the page instead of viewing it directly.

Secure Access Of PDF Within A Frame

For security reason, most of the professional would suggest that not to use the pdf file directly inside the page so that it go out of range and some of the wording may not be visible or you have to scroll in order to view it. For this reason, you need to create a frame and implement the pdf document within the certain range of the screen and make them to visible with best clarity. Chrome is the browser which fails to update the pdf file rather it must be scaled to 100{37256cf0ee31db86add5b6eba3983cfb5fab0b039501789ef81a53d1a467d5f8}. In internet explorer browser, you need to install the pdf plugin similar to adobe reader software in order to make the pdf document to visible. In mobile browser, one should need to download the file the internal storage or external storage in order to view the pdf document. At maximum time, please avoid using the pdf file rather make use of word documents.

Configure Automatic Daily Backups for FREE in WordPress

WordPress has some special features that are really suitable for modern technology that helps to adopt most of the package rather non acceptance. There are various plugins are been introduced on daily basis in order to backup the information for future usage.

Backup Daily WordPress Plugin

Backup daily is the common plugin which most of the user used to make use of in order to back up the database on daily basis rather than performing the storage part all at once. There are various advantages are available that are as follows: This operation will help to store the database on day to day basis and free the database once in a week. This type of service will help to show cast the current updated process which is running currently as well as keep the storage space stable for long period of time. All the information which is stored at one place is been secure in confidential manner with robust authentication. If you are making use of the outlook then you have the option to back up the database of a particular site in the disk without any additional software requirement. One of the major feature is most of the people would like to host the site in free hosting or less expensive hosting server as well as they would like to store the information in secure manner.

Necessities Of Backing Up Database

In some situation, there may have a chance of hacking your site information and it can lose the data accidentally or some collapse may occur on the site that will mess up all the data that are irrelevant to the concept which you have delivered. In order to avoid these entire things, you need to backup the data in proper manner by making use of quality plugin. All the data that are stored similar to the cloud computing that is all the data which you would like to store will be assigned in the virtual storage in online or offline. Most of the cases would like to prefer online because the information that are available inside it will be highly safe and secure in all aspect to retrieve it without any problem.

Installation Process Of Plugin

  1. Open the wordpress dashboard.
  2. In the left side of the screen, click on the option called “Plugin”.
  3. And then select “Add New”.
  4. Search for the plugin called “Updraft Plus” plugin.
  5. Plugin would pop up.
  6. And then click on “Install Now”.
  7. Installation Process will run and Complete at One Stage.
  8. After that open it and “Activate It”.

Scheduling The Configuration Backup

There are two set of categories are available in order to files. One is file backup interval and other one is database backup interval. In the file backup option select the database storage on daily basis which will be roll back once in a week. Similar to that continue the procedure in the database backup interval which must retain once in a week.