Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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]
share|improve this question

2 Answers 2

up vote 1 down vote accepted
+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.

share|improve this answer
    
Thanks I'll try this out. –  drtanz Mar 15 '13 at 15:35
2  
This is so wrong. There is possibility that you dont want to convert everything. Adding a code to the_content is just wrong –  Ünsal Korkmaz Mar 19 '13 at 20:58

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/

share|improve this answer

Your Answer

 
discard

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.