What is WordPress core and how to use template tags


About the WordPress Core

Any good CMS will keep its core files apart so that you don’t ruin the code that makes the system work, and WordPress is no exception. Here, we’re talking about the WordPress core, which is basically everything that isn’t in the wp-content folder, where you’ll drop themes as well as plugins and uploaded files. All these things work on top of WordPress, so there’s no risk of actually ruining the actual system files (unless you’ve installed malicious code, but that’s a completely different matter) when you develop a site.

In fact, the whole idea is that the only time you’re editing or even doing anything outside of the wp-content folder is when you’re installing the system, and possibly when moving the install files to a different folder. Naturally, there is some cool stuffthat requires .htaccess editing, and I’m sure you’ll come across plugins that want you to do things outside of wp-content, and that’s fine of course, although you should be a bit cautious. The whole point, however, is that the WordPress core is untouchable. Don’t mess with it unless you really need to, and if you do, you should rethink and rethink again because the chances are there’s a better solution. Hacking the core is bad, and that’s why the wp-content-based theme structure is so good.

Using the Template Tags

Although WordPress is written in PHP, it is in fact a framework in itself. You can use PHP to do stuffwith your WordPress theme or plugin, but most of the functionality is managed with template tags. If you open a theme file (just about any file with the extension .php, like index.php or single. php) you’ll find a lot of PHP-like functions, such as this one, for example:

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

That is a template tag, and it outputs the weblog’s name. The PHP part, which consists of <?php at first, and ; ?> at the end, tells WordPress to process whatever’s inside it, and in this case it is the template tag bloginfo(). Inside the parenthesis you’ll find the parameter, passed inside the quotation marks. In other words, 'name' is the parameter above. You’ll be using bloginfo() a lot in your themes, for example for finding the theme’s directory. Let’s output an image called smashing.gif in a theme file, just to drive the point home:

<img src="<?php bloginfo('template_directory'); ?>/smashing.gif" />

You’ll recognize the img HTML tag of course. The bloginfo() template tag has another parameter here, template_directory. This outputs the path to the theme’s folder, called template directory instead of theme directory just to make things a little more complicated. And then you just add the smashing.gif file name to complete the path, and you’ve got a potentially working image path in your theme. Of course, you would need the image in the theme folder as well. So template tags are basically PHP functions that can handle parameters to do different things. Some have default values, others don’t, and some have more settings for you to play with than others. Most of them will work anywhere in your WordPress theme files, but some need to be within the loop. The loop is basically the code that outputs the content, like posts or pages.

You’ll find a complete listing of template tags in the Codex: codex.wordpress.org/ Template_Tags/. Consult it whenever you need to do something out of the ordinary within your themes, or when you want to alter things in an existing theme. Each template tag is described, along with usage and sample code to help you understand it. This is the beauty of WordPress: you can actually copy and paste your way to a different result without knowing any PHP at all.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.

Note: This article was sent to us by: Sean Jovers at 05152010

Related Articles

1. Show off Your Twitter for Wordpress
Integrating the social web Before digging into the various techniques used to display and connect to the social Web, it is important not to forget the most ob...

2. How to do lifestreaming with WordPress
Lifestreaming with WordPress Lifestreaming is a term commonly used to describe the mashing up of everything you do online. A bit presumptuous, perhaps, to assum...

3. Social Web Submit Buttons plugin Worspress
Social Web Submit Buttons The social Web is certainly a big consideration when working with editorial content today. While search engines can trickle in visitor...

4. Wordpress Hosted Comment Solutions
Pimping the Comments With the addition of threaded comments in the WordPress core, and the excellent CSS styling options that are now available, as well as the ...

5. How to Backing Up database for Wordpress
Backing Up Anyone who has lost data in a hard drive crash or similar knows the importance of backing up, and it goes without saying that this applies to your on...

6. What you need to know about the Wordpress database
Hacking the Database Most of the time you needn’t worry about the database; WordPress will do that for you. There are database changes between versions so...

7. Switch hosts with wordpress when export and import do not work
WordPress and Switching Hosts There are several ways of moving to a new server. My preferred one is using the Export/Import functionality found under Tools in W...