Just in case you have been visiting your Aunt Zoraphelia on Pluto for the last few years, here is a brief explanation of what a shortcode actually is:
“
… a WordPress-specific code that lets you do nifty things with very little effort. Shortcodes can embed files or create objects that would normally require lots of complicated, ugly code in just one line.
[
via]
”
Plugins often make great use of them. WordPress.COM has lots of them built in and you may already have some yourself. Anyway, here are few that are incorporated into this theme:
Please note: tags changed from [ ] to { }
{raw}{/raw} – disables the automatic post formatting [Note: When you use this one, you need to add your own html coding within a post]
{note}{/note} – provides a means of adding a note to a post or page that only the admin of the site can see
{adsense}{/adsense} – enables the addition of your Adsense within post and pages
{mailto}{/mailto} – to obfuscate an email address within your posts or pages. It renders as the following code.
email@em++
{php}{/php} and {css}{/css} – which are provided via the Syntax Highlighter plugin
{contact-form 1 \”Contact form 1\”} – used by the Contact 7 plugin
It is also possible to make your own simple text shortcodes. This is handy if you tend to type the same string of text over and over again. In the functions.php file you can find the following code:
// SHORTCODES - SIMPLE TEXT
// Add as many shortcodes as you wish. Very handy for sites that use the same text, wording etc again and again. For instance, add Have you checked out FreshlyPressed today? to any post and it displays the text within the code below]
// -----------------------------------------------------------------------------
function freshlypressed() {
return 'Have you checked out <a href="http://freshlypressed.net">FreshlyPressed</a> today?';
}
add_shortcode('fpr', 'freshlypressed');
This means that if I type in {fpr}, it will automatically pump out “Have you checked out FreshlyPressed today?”
You can make as many of these as you like using the above code as a simple example.
Oh, almost forgot to mention: Just for a bit of fun you can make your text talk like a pirate by using the {pirate}{/pirate} shortcode. Take a look at how it changes this news story from the BBC:
ORIGINAL TEXT:
Net pirates to be ‘disconnected’
Peter Mandelson, Business Secretary
Peter Mandelson intervened to toughen up UK piracy policy
People who persistently download illegal content will be cut off from the net, Business Secretary Peter Mandelson has announced.
Speaking at a government-sponsored forum to debate copyright issues he said the UK would introduce a similar policy to France.
It means persistent pirates will be sent two warning letters before facing disconnection from the network.
The issue has divided the telecoms and media industries.
Mr Mandelson said that cutting internet connections would be a “last resort”.
“I have no expectation of mass suspensions. People will receive two notifications and if it reaches the point [of cutting them off] they will have the opportunity to appeal,” he told the audience at the C&binet Forum, a talking shop set up by government to debate the issues facing the creative industries.
PIRATE TEXT:
Net pirates t’ be ‘disconnected’
Peter Mandelson, Business Secretary
Peter Mandelson intervened t’ toughen up UK piracy policy
People who persistently download illegal content will be cut off from th’ net, Business Secretary Peter Mandelson has announced.
Speakin’ at a government-sponsored forum t’ debate copyright issues he said th’ UK would introduce a similar policy t’ France.
It means persistent pirates will be sent two warnin’ letters before facin’ disconnection from th’ network.
The issue has divided th’ telecoms an’ media industries.
Mr Mandelson said that cuttin’ internet connections would be a “last resort”.
“I have no expectation o’ mass suspensions. People will receive two notifications an’ if it reaches th’ point [o' cuttin' them off] they will have th’ opportunity t’ appeal,” he told th’ audience at th’ C&binet Forum, a talkin’ shop set up by government t’ debate th’ issues facin’ th’ creative industries.
Categories: Features, Instructions | Tags: shortcodes