April 9, 2008

WordPress 2.5 implemented a new way of inserting content into posts: shortcodes. If you haven’t had the need to use the new gallery shortcode you might not have come across the details. So, what are they?

Plugin authors have used all sorts of methods of adding codes to posts to specify where the content of their plugin should be included. Shortcodes takes this idea, and builds a standard method into WordPress.

There is one included in WordPress 2.5 by default and that is the gallery shortcode. The gallery shortcode inserts all of the images that are attached to the post into that post using one simple code that looks like this: [gallery]

Shortcodes also accept options so, for example, if you wanted to include the gallery from a different post you can specify the post id, like this: [gallery id=”6″]

The gallery shortcode also lets you specify the order of the images, the size, the way they are marked up, by default it uses a definition list, and the number of columns. You can read more about the options in the gallery shortcode at the WordPress Codex.

Shortcodes can even be used to surround text, if the plugin requires it: [code]Some text here[/code]

Shortcodes should help to bring consistency to the way plugins work, helping users to get to grips with them more easily, but also help plugin authors. There is an easy to use API that takes the work out of producing plugins that find and replace content, or even just insert it, with options.

I have used it for one plugin so far. Fun with Photo Data displays EXIF data in a list. While it wasn’t difficult to create without shortcodes, using the Shorcodes API made it easier still. For complex plugins this could be make a significant difference.

My WordPress plugin generator has been updated to include shortcode functionality and you can read more information about the Shortcodes API at the WordPress Codex.



Wordpress title showing space?
no comment on page 1371

Wordpress fun?
one comment on page 1376

Live blogging plugin?
4 comments on page 1258

Wordpress 3 admin speed up?
4 comments on page 1321

Framework photoshop?
3 comments on page 296

Fun wp plugins?
one comment on page 1376

Habari vs wordpress?
12 comments on page 440

Wp tags vs categories?
12 comments on page 7

Wordpress rss seo?
one comment on page 1361

Photo albums html5?
6 comments on page 1305

Wordpress chat?
no comment on page 1308

Wordpress exif data?
12 comments on page 230

Css sidear tab?
2 comments on page 336

Wordpress theme html5 blueprint?
6 comments on page 1305

Wordpress shortcode in plugin?
no comment on page 236

Html 50 photo album?
6 comments on page 1305

Get the post attachement?
24 comments on page 1065

Wordpress plugin development 30?
one comment on page 1373

Wordpress plugin development 30?
one comment on page 1373

Disqus formatting?
7 comments on page 1175

Html5 photoalbum?
6 comments on page 1305

Html5 photoalbum?
6 comments on page 1305

Wordpress fun?
one comment on page 1376

Fun wordpress plugins?
one comment on page 1376

Url shortener ideas?
4 comments on page 1190

Url shortener ideas?
4 comments on page 1190

Html 5 photo gallery?
6 comments on page 1305

Multiple post navigation?
no comment on page 1147

Html5 photo galleries?
6 comments on page 1305

Adding images to a wordpress 3 post?
24 comments on page 1065

Html5 photo gallery code?
6 comments on page 1305

Wordpress multiple blog master?
one comment on page 1376

Wordpress 3 tableprefix?
2 comments on page 1374

Wordpress 3 tableprefix?
one comment on page 1376

Using wordpress as a framework?
2 comments on page 335

Single post image size?
24 comments on page 1065

Get featured image src wordpress?
24 comments on page 1065

Disqus wordpress mu?
7 comments on page 1175

Wpgetattachmentimagesrc size?
24 comments on page 1065

Image gallery html 5?
6 comments on page 1305

Wordpress theimage?
24 comments on page 1065
  every 1744s, 1s ago, in 0.03s.
Post a comment?

0s