Every good thing has a bad side to it, and so is WordPress. Though it is something which comes with a number of advantages and is pretty easy to work on, there are a number of things which might boggle you from time to time and might not prove to be the best decisions you made related to work. WordPress is also liked and preferred by people as there is a huge amount of helpful data available online for developers and they can get access to it quite easily. For every developer working on a WordPress theme and other related aspects is very important these days, and in this article we will talk about a few mistakes which have been committed quite often in the past and tips which they should make use of, to avoid these shortcomings.
Say No To query_posts()
Query_posts are something you really should not use as it just slows down the whole process as you will have to take time out to clean up the mess which has been caused by the number of applications which are running in the background due to the WP_Query. This is because when you first call a query_post() you are instead calling 2 posts as the first one was called before calling the template files, which also means that now you have opened 8 queries as WP_Query also loads 4 Queries and other posts. Clearly it is a lot of mess, and nobody to clean it up but you.
To avoid this problem, there are a few steps you can take. First of all, if you know you require more than one loop in a page, then you should use WP_Query object as it is a better option. Next thing is to use pe_get_posts for the modification of the main loop and the third thing is to use get_posts() if a loop is not needed. It will solve your problem of too many codes.
Stick To Adding Body Classes
< body class="home blog logged-in content-sidebar" >
This code is something which will make your life much more convenient and its time to get to know it, if you still are not aware of it. This is the code which belongs to WordPress and is a function to add classes to the body, regardless of where you are. Not just this, you can do a number of things using it including adding backgrounds, different styles and message. Basically, it is here to make things easier and now is the time to embrace it.
Cache your Queries
This is for plugin developers who still do not make use of transients API. Transients API basically helps you by allowing you to store "options" for sometime and you can set a transient for every 15 mins so that you do not have to keep track of the new tweets or messages all the time and all you have to do is load them later on. You can even cache your entire query at once which makes it even more convenient for you.
It is Time to Get Familiar with Plugins
As we discussed in the beginning of the article, WordPress and its developers have done everything to make the whole system easier, and plugins play a huge role in that. There is a plugin for almost everything you can think of and if you are not using them already, you are not making the most out of WordPress. Right from caching and optimization to CSS and JS minifying, there is a plugin for all your needs and they will help you in improving how your website works.
Start Compressing Files with GZIP
This is basically making life much easier, and it can be done by compressing your site filed by adding the below mentioned snippet to your .htaccess file. Once you have done it, you will be able to send compressed files to users with the help of server-side GZIP.
#Gzip < ifmodule mod_deflate.c >
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
< /ifmodule >
#End Gzip
#Gzip < ifmodule mod_deflate.c >
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
< /ifmodule >
#End Gzip
These few tips are important and if you stick to them, a large amount of your work will be eased out.
About the author : This article is contributed by ValueCoders, a leading outsourcing company india, specialized in web and cms development. One can hire WordPress developer here for effective WordPress development services.
No comments:
Post a Comment