In the previous post we have covered
- Setting up CDN (content Delivery Network) with the wordpress blog.
- Tweaked the .httaccess file like removing hotlinking( protect your images from bandwidth theft)
- optimized images with the wp minify and wp smush it.
- Using cache plugin using the Wp-total cache
- Enabling Gzip in the.httaccess file.
So Now we are moving ahead with adding the ajax pagination effect in the wordpress blog .
Tutorial
- Log on to your wordpress dashboard .
- Go to Editor in your wordpress dashboard
- Now you can see source files of your wordpress blog.
- Find the header file (header.php) and click on it.
- Now you can see the header.php code , now here you have to add the following code before wp_head() function. You can find the wp_head() function by typing “CTRL +F” then type “wp_head()” and paste the following code before the header function.
<?php wp_enqueue_script('jquery'); ?><script>jQuery(document).ready(function(){// ajax paginationjQuery('#wp_pagination a').live('click', function(){// if not using wp_pagination, change this to correct IDvar link = jQuery(this).attr('href');// #main is the ID of the outer div wrapping your postsjQuery('#main-container').html('<div><h2>Loading...</h2></div>');// #entries is the ID of the inner div wrapping your postsjQuery('#main-container').load(link+' #entries')});}); // end ready function</script>- So after adding above code in your header.php and click save button.
- Finally you have optimized the website faster with Ajax pagination which makes your site even faster .