Information Technology Reference
In-Depth Information
IV
search box so your visitor can find what he was looking for. As we noted earlier, you can include
plain HTML inside the PHP code:
<?php else : ?>
<h2 class=”center”>Not Found</h2>
<p class=”center”>Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . “/searchform.php”); ?>
As you get more into plug-ins, you'll notice that some of them will tell you to place the code inside
The Loop. Now you know where that is.
Further down the Index page, you will see how the sidebar and footer templates are called into the
main page, because what's the point of having a blog page if your blogroll is not on it?
Custom Post Types
WordPress includes four basic post types: Post, Page, Revision, and Attachment. Post types are
stored in the wp_posts database table. The ability to add custom post types is included in version
2.9. It doesn't do much in this first iteration, but what a future this option has.
In Chapter 12, “The WordPress Toolkit: Themes,” we talked about the Semantic Web and identify-
ing content for what it is, not necessarily how it looks. Custom post types point in that direction
and create some new formatting opportunities. Let's say you run a music blog. While most of your
posts may just be your thoughts on bands and such, you also review new music. To serve your visi-
tors, you want to include some basic information about the track(s), artist(s), CD title, and the like
with links to where people can get the track. You can create a Review post type and include fields
for this information in your theme's CSS.
Unfortunately, you can't do this just yet. In v2.9, you get three basic functions to include in a
plug-in:
get_post_type() —Returns the current item's post type in The Loop. This function is identical
to $post->post_type.
get_post_types() —Returns an array of all post types.
register_post_type($post_type, $args_array) —Called from within a plugin or functions.php.
Only one available argument: “exclude_from_search”
Essentially, all you get to do it register a new type as being searchable or not. For now, you still
need to define custom fields and retrieve them in your theme files. The cool stuff isn't built in—yet.
This option is pretty exciting, but is mostly a developer plaything until at least version 3.0.
The Sidebar Template
This template handles the content and placement of your sidebar material. You can drop widgets
here, if your theme allows it. Otherwise, you must use tags and parameters to define your sidebar.
Template tags are basically PHP functions inside WordPress. For example, earlier in the chapter we
showed you the phpinfo() function to display information about your PHP installation on your
Search WWH ::




Custom Search