0

I'm using TinyMCE Advanced and SyntaxHighliter plugins on my WordPress install.

Why does the editor change my inserted code, from:

[php]
<?php
/**
echo('code');
/**/
[/php]

to:

[php]
<!--?php <br ?-->/**
echo('code');
/**/
[/php]

2 Answers 2

1
+50

I suggest you to use htmlspecialchars() before sending content andhtmlspecialchars_decode() before showing content on page, here is functions that you need to copy/paste to your functions.php :

function wp_po9568($content)
{
    return htmlspecialchars($content);
}
add_filter('content_save_pre','wp_po9568');

And:

function wp_po5689($content)
{
    return htmlspecialchars_decode($content);
}
add_filter( 'the_content','wp_po5689');

Wordpress by default comments out php tags.

1
  • 2
    This is so wrong. There is possibility that you dont want to convert everything. Adding a code to the_content is just wrong Mar 19, 2013 at 20:58
0

You can use this filter on your theme functions.php

remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);

This will remove extra P and line brake from short-code. More details will found here http://dynamicweblab.com/2012/10/removing-extra-p-and-line-breaks-from-shortcodes-in-wordpress/

Your Answer

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

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