0

I am trying to make a post where there is a text line :

some libraries to run which we will import by using "#include <filename.h>" command.

instead of outputting the text as it is. It shows as:

some libraries to run which we will import by using “#include ” command.

in post so <filename.h> is missing for some reason. I am quite sure I am missing something here but unable to find. I think for some reason WordPress escapes anything between <> tags so how can i show them if i need to?

1

You have to escape th < and the > with &lt; and &gt;, otherwise WordPress will remove the “unknown tags”.

You could also filter pre_kses to change the output before it gets stripped.

add_filter( 'pre_kses', function( $str ) {
    // find and escape < and > on specific positions, then
    return $str;
});
  • is there anything that I can add before < and > chars to escape them like in most programming languages like java or c we add "\" to escape them? – Deepak Feb 6 '14 at 22:17
  • @shunya Yes, see my update. – fuxia Feb 6 '14 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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