Information Technology Reference
In-Depth Information
15
web server. WordPress has an equivalent template tag called
bloginfo() . Note the parentheses after the function; parame-
ters are declared inside the parentheses.
Even when there are no parameters at all you want to display,
you still have to type the parentheses to show that this tag has
no parameters to set.
If a tag has parameters, it will be one of these types:
Boolean —This provides a True or False answer that can be
displayed as a binary number (0=false and 1=true).
Integer —This is a positive or negative number. You will
sometimes see these inside single quotation marks ('42').
String —This is text, which can range from a single letter to
a list of words. Strings, regardless of their length, will
always be inside single quotation marks. A string either sets an option for the parameter or dis-
plays text on the screen.
note
If you already know PHP, consider
whether you want to use other
people's widgets (and not have to
worry about code) when looking for
a theme to use as a basis for your
own unique vision. Some themes
don't support widgets and only use
template tags to create sidebar
items.
Look for phrases like “widget-
ready” or “supports widgets” in a
theme's description.
Let's look at one common template tag to show you how tags and parameters work together in a
sidebar item.
Use the get_archives() template tag to link to your archive of old posts. The Arclite theme
includes a monthly list in its default sidebar. The code looks like this:
<?php wp_get_archives('type=monthly&show_post_count=1'); ?>
Two parameters are set here, separated by an ampersand ( & ).
type identifies how much time is represented in these
links. Type a string value of daily (if you write multiple
posts per day), weekly , monthly , or postbypost (for a
collection of the most recent items).
show_post_count is a Boolean value indicating that you
want to show the number of posts in each archive link. So
if you post once a day, your sidebar links as set previously
would look like this:
February 2009 (28)
March 2009 (31)
April 2009 (30)
note
Parameters are similar to (and
sometimes called) “arguments” in
a command line statement. The list
of colors we used in the “Variables,
Strings, and Arrays” section would
be parameters for a color() func-
tion. Generally speaking, function
parameters are enclosed by
parentheses.
note
Those who cringe at the sight of the words Boolean and integer: Be not afraid, no math is required to use
WordPress template tags. Everything you need to know about each template tag and its parameters is waiting
for you at the WordPress Codex.
Visit http://codex.wordpress.org/Template_Tags. Scroll down to the Tags section, and click the link of the tag
you want to use to see all its parameters and how to use them.
Search WWH ::




Custom Search