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.

2 Answers 2


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.

  • It seems to be exactly what I require. Generating the special content at post writing time is perfectly acceptable.
    – SF.
    Commented Jul 4, 2013 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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