2012年4月7日星期六

12 Essential Tips to Build Your First Wordpress Theme

Guest article by Sandip Dedhia from BlogsDNA
I always wanted to contribute to the wordpress community by building a WordPress theme and releasing it to public. After efforts of 20 days I just managed to finish my first WordPress theme. It was a great learning experience for me. During this process I ran into several issues, and it took considerable time to get it solved.


Creating Your First WordPress Theme


Here I am listing some important points which you need to keep in mind before starting to build your own WordPress theme, which might save you from such issues.


1) If you are not an experienced PHP developer, then dont start from scratch, instead take default or classic theme to start building your own WordPress theme.


2) Get your index.php file perfect as this is the most essential file you require in your WordPress theme, rest of the files are optional. Also you need little code change in your index.php file to get the rest (category.php, archive.php, single.php etc.) of WordPress theme files.


3) Always start with the new and latest installation of WordPress while building your theme. It happened that I used my old existing WordPress blog which had several edited core WordPress files and as soon as I tried to use the developed theme on the newly created WordPress blog, I ran into unexpected behavior and it took me several days to find out what went wrong.


4) Keep modular code as this will save your lots of time and effort while integrating your style code with PHP code.


5) Generically use PHP echo statements to find out which code is responsible for a particular output. But dont forget to remove those echo statements at the end.


6) Dont ever hardcode any URL, Variables values, Image path inside your WordPress theme if you are planning to release this theme for the public.


7) WordPress Template Tags are great time savers to theme developers as they always experiment with various tags to get the desired behavior.


8 ) There are several sites which provide big lists of WordPress Loops. Do check out those lists and try to reuse available code as much as possible as this will save lots of development time.


9) If you have reused any code from any other theme or website, do check whether that code includes any deprecated functions/Template tags. Try to avoid using them and replace with alternate Functions/Template Tags.


10) Dont include unnecessary PHP code, white spaces and blank lines in your WordPress theme. This makes your theme heavy and leads to slower loading of pages. Take extreme care of white space before the start and end of php code tag, since it will result in those Header already sent nasty php warnings.


11) At the end if things go out of control, dont fear to ask your question at WordPress codex community


12) Lesser the php code, fewer the database calls, faster the response time keep this mantra in your mind.


Trust me you dont need to be expert in PHP to build a WordPress theme. We have great resources available at WordPress official website. Do read the Theme Development guidelines on WordPress.org before proceeding to theme development. I hope above points will be helpful to all the bloggers and developer who are planning to build their own WordPress theme first time.


This guest article is written by Sandip Dedhia from BlogsDNA. where he blogs about Technology, Web 2.0, Linux, Gadgets and Blogging Tips. Got some tips to share, you can also write a guest article on QOT.





Related articles you might like ...

没有评论:

发表评论