WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there some way - a plugin, a technique, some file to edit - to define some custom markup to be interpreted, parsed and replaced with custom, generated content when generating posts?

The simplest example of what I want would be smileys, getting a :) or in text of the post replaced by a specific <img scr="..."> when generating the HTML, or custom version of BBCode, but in my case the generated content would be more complex, at the very least requiring the use of the post ID, but probably more, so I'd prefer a PHP-side solution working somewhere under the the_post() surface, not a simple client-side Javascript rewriter.

share|improve this question
up vote 1 down vote accepted

You are probably looking for The Shortcode API that allows to create shortcodes like [my_shortcode] and [my_shortcode]some text[/my_shortcode] to be used in content and other shortcode-enabled areas.

More advanced technique are way more involved and might require storing editable and rendered representation of content separately or do apply custom rendering filter every time content is displayed.

share|improve this answer
It seems to be exactly what I require. Generating the special content at post writing time is perfectly acceptable. – SF. Jul 4 '13 at 15:05

If you wanted to do something more advanced than shortcodes, you can also write a plugin that utilizes the Filter API on the_content to apply some sort of transformation when post bodies are displayed.

This approach (but with other filters upon saving the editor) is essentially the basis for plugins like WP-Markdown, which allow you to write in the lightweight Markdown syntax.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.