PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

SitePoint PHP Blog: How to Create Your Own WordPress Shortcodes

Note: This article was originally published at PHPDeveloper on 12 November 2010.
PHPDeveloper

On the SitePoint PHP blog today there's a new post showing how how to make your own "short code" system that allows for custom function execution.

WordPress doesn't normally allow you to add PHP code to pages or posts. That's for the best: you don't want clients to discover the power of the unlink function! However, you can create custom functions which are executed when a shortcode is encountered within the post text.

There's two code snippets included - one showing a simple function call, "Hello World" style, and another version that lets you define parameters to feed into the method. There's also a simple example of how you could allow them to include CSS styling into the code example too.