The thing I like the most about working with WordPress is its ability to do everything and anything you need it to. When designing a theme, or when using a a pre-made theme, WordPress offers quite a few conditional tags to help customize its look and feel to suit whatever your needs may be.

Conditional tags are used within PHP to state that you want something to happen only “if” something else happens first. For coders this is known as an “if” statement as well.

So for example, the conditional I use the most is the is_home() tag.

Here is what it would look like.

if(is_home()) {
     echo 'Welcome to my home page!';

Now of course, the above code doesn’t do anything that special other than display “Welcome to my home page!”, but it will only do it if the current page is the home page. You can place this in your sidebar.php file and it will only appear when you click onto the home page. Like I said, this piece of code is nothing special but thing about just how helpful these conditionals can be when designing your site.

Here is a list of tags that I use the most.

  • is_home(): appears only on the home page
  • is_single(): appears only on that specific post
  • is_page() : appears only on that specific page
  • is_category() : appears only when in a specific category

These are only the few of the conditional tags offered by WordPress. Check out the WordPress codex for a complete list and more examples.