WordPress shortcodes are brilliant. They give you so much flexibility in the manner you deliver content, and their use will simplify use of integrated functions for the less tech-savvy. In a sense, they are an alternative to allowing PHP execution delivering dynamic content within a post. You can create simple functions that will easily deliver content within a post or parse text in a certain manner with the use of simple pre-defined code.
Basically, some code (shortcode) within your post is recognised by WordPress and converted into other more useful content as defined by a function designed to accomplish a particular task.
This video from WordPress shows how easy it it to insert a YouTube (and other) videos into your WordPress.com post using shortcode rather than using the provided embed code. Think of it as kind of “BBcode“. Shortcode = shortcut.
Here’s the simple “Hello, World” example that WordPress uses on its website to describe the basic principles of shortcode use.
function hello() {
return 'Hello, World!';
}
add_shortcode('hw', 'hello');
If you posted this code into your functions.php file, or in the case of Thesis, your custom_functions.php file, including the shortcode of [hw] into the html component of your WordPress editor (into a saved post) would output “Hello, World” in its place.
Read about shortcode here and here on the WordPress website.
We’ll post examples of its use soon.
|
|
If you liked this article, you may also like:


[...] Continuing with the ongoing series of posts on shortcode, here’s some examples of how you can fancy up your posts – or use styled elements in a [...]