Exploring Template Tags, Values, and Parameters
Some people are intimidated when they look at template tags. Really, they're just a simple bit of PHP code that you can use inside a template file to display information dynamically. Before starting to play around with template tags in your WordPress templates, it's important to understand what makes up a template tag and why.
WordPress is based in PHP (a scripting language for creating Web pages) and uses PHP commands to pull information from the MySQL database. Every tag begins with the function to start PHP and ends with a function to stop PHP. In the middle of those two commands lives the request to the database that tells WordPress to grab the data and display it.
A typical template tag looks like this:
<?php get_info(); ?>
This entire example tells WordPress to do three things:
- Start PHP (<?php).
- Use PHP to get information from the MySQL database and deliver it to your blog (get_info();).
- Stop PHP (?>).
In this case, get_info is the actual tag function, which grabs information from the database to deliver it to your blog. What information is retrieved depends on what tag function appears between the two PHP commands. As you may notice, there's a lot of starting and stopping of PHP throughout the WordPress templates. The process seems as though it would be resource intensive, if not exhaustive — but it really isn't.
For every ...
Get WordPress® All-in-One For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.