10 common WordPress theme mistakes and how to prevent them

10 common WordPress theme mistakes and how to prevent them

When I talk about WP, the first thing that comes to my mind is WP themes. It is like an exquisite collection of a family heirloom, which you keep in store, protect it and when required, you use it. But, you don’t neglect it, or rather, keep your own daily usable in it. 

How can you nurture your WP themes? Below are the listed nitty-gritty details of the common WordPress theme mistakes and how you can avoid them to ensure the theme's usability remains the same.

  • Don’t plan way ahead - When you are creating your website, you might want to think about how the future of your project is going to look like. You will think about the layout, the features, header, footer and other as such. 

In order to keep your creation the way you thought it would be, you write functions in such a way that will save you repetitive coding, extra loops, etc. But, while you were lost in your future, you didn’t realise those planning weren’t needed. So, go step by step, and code accordingly.

  • Know how and when to optimize - A developer optimizes in two ways --- a) correctly, or b) prematurely. You tell me which category you fall in. Yes, that's the idea. We all want to optimize correctly. The reason behind this is that premature optimization of your code can cause you problems with your theme. You will assign a value to a variable and think that will save you time. Well, in real-time cases, it is not helpful.

You might be habituated to optimize your code, but, before you do so, stop and think for a while. Ask yourself if it is necessary to optimize. You might need to more function calls, but that’s Ok. It all depends on the project you are working on.

  • Don’t use variables in your template - One of the best ways to reduce variables in your theme templates is when you reduce over-optimization. Another way is, try to avoid the use of variables in your files itself. This will help in improving readability and remove the dead weight.

Another thing, instead of defining your variables, extract them in your functions directly. By doing so, you are fetching the same result, without overcomplicating those template files.

  • Say no to out-dated versions - If you are using WP for a while now, you must be aware that it has the habit of updating it features a lot. Thus, your code should evolve along with the ways. Henceforth, use the latest updates and the best practices, so that your code is dynamic.

This point is more important if you building themes for others to use. Keep a regulatory eye on the codex to ensure you are always following the best practices and using the latest updates.

  • No support or plugins - One of the biggest reasons for WP to be popular is because it provides added plug-ins that help us in coding. However, there are a lot of themes which need extra plug-ins to be added or don’t have extra support. Know about these in detail and then only dive for the haul.
  • Pay attention to your license - Instead of custom creating a theme, maximum of us buy pre-built themes, as they are cost-effective. All is fine, except you need to check on the license. Just like any other bought device, a WP theme comes with a license of its own. Before you buy your theme, please check the type of license the theme comes with. It can be either of the three:
  • One-time fee, including lifetime updates and support
  • Recurring annual or monthly payments for access to updates and support
  • Premium paid support on an ‘as needed’ basis

Be thorough with your requirement and then only purchase your theme. 

  • Way to go natives!  Let’s consider you have written code and haven’t used any predefined/ native function in your programming. The problem it will have is that the next person who will use/ tap into your theme, be it a child theme or a plugin, they won’t be able to do so. So, it is always advised to use native WP functions wherever and whenever possible. This keeps the code more universal and helps others to refer to it.
  • No, don’t build your own framework - For a coder, a “dry” code is always an expectation. A reusable, clean, clutter-free code is a goal.

To achieve those and to avoid a few extra lines, we sometimes create, as we all know it, a “my framework”.The biggest problems of my framework are:

  • Maintainability issue
  • Plugin customization, which can’t be used by other developers. Rather create your plugin and this will help the open-source community.
  • Increased complexity. 

Thus, it is always better to abstain from creating your own framework. As I have stated earlier, we are all artists, all developers are. So, let’s create art.  

  • Incorrect enqueuing - When you are enqueuing you must use the correct function. For example, .css and  .js files of your themes must be enqueued with: wp_enqueue_style() for CSS and wp_enqueue_script() for Javascript.

Another common error is to hardcode scripts directly into the <head> or sometimes, before the </body>. Due to this, there will be duplicate loading and you can’t remove a resource. 

So, next time please hardcode your jQuery into the <head> section. 

  • Why prefix? In the language of coders, a prefix is a way to ensure your code doesn’t clash with the plugins. In PHP, namespacing does the same. You should prefix the below-listed things:
  • PHP function names.
  • PHP class names.
  • Script handles.
  • Image size names.
  • Style handles.
  • PHP global variables.
  • Action/Filter hooks.

The simplest way to prefix anything is to use add_ or - to your theme name. If your theme folder has two words like “folder name”. Then you can prefix it by folder_name_ or folder-name-. In the same way, if your function name is hello_world(), you will prefix is by foldername_hello_world(). 

While I have tried to enlist the top 10 common WP theme mistakes that you can avoid, still there are few that need the honourable mentions. Those are:

  1. Mobile friendly theme
  2. Functionality based theme
  3. “Nulled” themes.

Now that a few of your questions related to WP are answered, I hope I can be of more help to you. Let me know how the articles and posts are coming up.  I am hoping you people will drop in with your comments.


#WordPress #WordPressThemes #Websitedevelopment #WordPressMistakes #Webdeveloper

Swarnendu Dutta

Marketing, RevOps & GTM Engineering | Scaling Growth with AI & Automation

5 年

A detailed and insightful read !

Stop using WordPress for a website

回复

要查看或添加评论,请登录

Rina Chhadwa的更多文章

  • Checklist for launching a website

    Checklist for launching a website

    It is no rocket science that launching a website is a mammoth task. Not only do you need to keep a tab of the work you…

  • 10 useful SQL Queries To Clean Up Your WordPress Database

    10 useful SQL Queries To Clean Up Your WordPress Database

    While working on WP is a great experience, however, all your work piles up and in no time, it can become a hefty…

    3 条评论
  • How to choose the right platform for your business?

    How to choose the right platform for your business?

    There are a few platforms which you can choose while you build your/ anyone’s website for the first time. Choosing a…

  • Are you a cafe owner? 5 things to know before designing your website

    Are you a cafe owner? 5 things to know before designing your website

    Owning a cafe great. There are few cafes that are my absolute favourite.

  • 15 things I learned in my 15 years of career

    15 things I learned in my 15 years of career

    In the work community, we always talk about the value that experience brings. It is one of the main reasons why…

    1 条评论
  • Why using a Framework is a great idea?

    Why using a Framework is a great idea?

    Hello folks! How have you been? I had a great time this Independence Day (you peeps saw the pic, didn’t you?) Today…

  • 10 Web Development Definitions You Need to Know

    10 Web Development Definitions You Need to Know

    #WebDevelopment is the process of building, creating and managing websites. This process includes web design, web…

  • 1 Drupal tip I live by

    1 Drupal tip I live by

    David Wheeler once said’ “All problems in computer science can be solved by another level of indirection.” When it…

  • 5 Time management techniques for Mompreneurs

    5 Time management techniques for Mompreneurs

    How many women you know who had to leave their jobs to be a full time mom? Yes, the numbers are high. Being a mom is…

    3 条评论
  • Happy Independence Day!!

    Happy Independence Day!!

    #HappyIndependenceDay guys! It's been 72 years that our motherland has been independent. We have come a long way since…

社区洞察

其他会员也浏览了