Another simple, yet powerful way to give your users more control over the theme is through a technique that WordPress calls shortcodes. Shortcodes are like widgets, except that they can be added directly to the content of posts using a predefined code. You may already have experience with WordPress shortcodes if you've used the gallery or video embedding codes built into WordPress versions 2.9 and up.

For example, Figure 7.5 shows how to embed a gallery shortcode into a post, and Figure 7.6 shows how the gallery displays on the site (this assumes, of course, that images are added to the post's image gallery).

Simple gallery test

Permalink: h«|j:/yiocalhost:H888/worcjpre5s30/?p = lSj Change PermalLrlcs View Post

Upload/Insert B B J O Visual HTML

| b || / || jjnk || b-quoie || del || ins || img || ul || ol || li || code || more || lookup |[ dose tags j There are nine images attached to this post, Here's a gallery:

[gallery columns="3"]

It's the simplest form of the gallery tag. All images are From the public domain site

Word count: 29 Last edited by Louis on June 22, 2010 al 4:14 am

Figure 7.5. The gallery shortcode in a post

There are nine images attached to this post. Here's a gallery:

It's the simplest form of the gallery tag. All images are from the public domain site

Figure 7.6. The resulting gallery display

The principal benefit of shortcodes is that they allow your users to add content with specific styles and markup that may be beyond their own abilities to produce. If you have a simple shortcode that produces the desired result, all you need to do is give them a few examples of how to use it.

Was this article helpful?

0 0

Post a comment