WordPress Tip: Be Careful with your Element Naming!

Just a minor tip to avoid your themes breaking...

  1. CM30
    Seriously, if you plan to use Wordpress for your site and are making a custom theme for it, be careful around the whole '<?php body_class($class); ?>>' thing in the template and what you name your actual page elements.

    Why? Because as I found out just now, it's all too easy to accidentally have the body class set to be the same as another random element on the page (such as if you use 'category' in your ids/classes for anything), and then have the entire page layout break almost beyond repair for no apparent reason. And if this happens, it's almost impossible to know why since the offending element isn't even part of the template that's being messed up.

    So yes WordPress theme makers. Don't make the mistake I did and name an element in the template 'category' or some permutation of it. Not unless you want you want the page to get messed up whenever the archive.php file is in use (such as on a post category listing). And if you do use it, remove that class thing from the body tag for your theme to avoid it messing with the style of the rest of the page.
    Brandon likes this.

Recent Reviews

  1. Brandon
    Brandon
    5/5,
    thanks for the tips!