Theme Tip 4 – Learn WordPress theme template tags

by

in

If you’re going to be spending any amount of time at all hacking around a WordPress theme, there’s one thing you’re going to want to get to know really quickly that will make your life so much easier. Template tags are basically the building blocks of WordPress themes.

What are template tags?

The little bad boys are the glue between your html/css and WordPress.

The humblest example of all is:

[codesyntax lang=”php”]

<h1><?php bloginfo('name'); ?></h1>

[/codesyntax]

Nearly every WordPress theme will have that template tag.

Another tag which is almost definitely in your theme is:

[codesyntax lang=”php”]

<?php the_title(); ?>

[/codesyntax]

But this is just scratching the surface. You probably already know what those template tags do. But did you know there are tons of these which can could save you tons of time when you started tweaking your WordPress theme to do what you want it to do.

For example:

[codesyntax lang=”php”]

is_category('blue-cheese')

[/codesyntax]

could be used if you wanted to display a big block of blue cheese above posts that are in the blue-cheese category.

Seriously folks spend 30 minutes having a look through the WordPress Codex on template tags.

Really important stuff.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *