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

I'm using a Markdown plugin and trying to write a blockquote

Like this

But Wordpress converts ">" to an html entity, so the result looks

> like this

Is there a way to avoid this?

share|improve this question
up vote 2 down vote accepted

Filtering the_content

function wpse72941_content_filter( $content ) {
    $new_content = '';
    foreach( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) {
        $new_content .= preg_replace( '/^>/', '>', $line ) . '\r\n';
    return $new_content;
add_filter( 'the_content', 'wpse72941_content_filter', 1 );

I don't know your markdown plugin - for the above approach, I have assumed that the markdown is interpreted after the post is retrieved from the database and not before it is saved to the same. I.e. that the markdown plugin also filters the_content.

The regex ^> matches > iff those are the first four characters of a string. In the above, the content is iterated over line by line, hence all > entities at the beginning of a line are converted back to > characters.

When the filter is added, we set the priority high (1), such that our entity conversion will run before the markdown interpretation.

The above will work when added to your theme's functions.php, but probably would be a better fit in a plugin. Actually the markdown plugin should take care of it itself.

Preventing TinyMCE from converting entities

If you need to stop the entity conversion right where it happens, before it is written to the databse, you will have to alter TinyMCE's (the editor's) configuration, the entities and/or entity_encoding options look promising.
There is the tiny_mce_before_init filter that can pass custom config values to the WP editor.

I would have provided a working example as well, were it not for this:

Encoding Type: raw | All characters will be stored in non-entity form except these XML default entities: & < > "
from the TinyMCE documentation on entity_encoding

So for the specific entity in question, this appears to be more involved.
This might also be the reason for why disabling the visual editor might not suffice.
Possibly a combo of 'named' as a value for entity_encoding and a list without gt for entities might do it.
Otherwise the onPostProcess event would be a last way to go.

Life would be simpler though, if the above assumption was true and filtering the post on database retrieval would suffice.

share|improve this answer

If you are using visual editor then > will automatically be converted. Turn off visual editor and use it.

share|improve this answer
I disabled the visual editor via the user edit page (disable advanced editor), but it's still happening. I'm not sure if that is the correct option though. – Donovan Nov 17 '12 at 12:31

I solve it using:

function my_content_filter( $content ) {
    $new_content = str_replace('>','>',$content);
    return $new_content;
add_filter( 'the_content', 'my_content_filter', 1 );

I think it's not glamorous, but, it work..

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.