Rectangle 27 3

Old post but this is how I fixed it... Try throwing this code into a plugin or your functions.php file.

function remove_bad_things(){ ?>
<script>

jQuery('#content-html').click(function(){
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// <![CDATA[','') );
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// ]]>','') );
});

</script>
<?php }

add_action('admin_footer','remove_bad_things');

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 3

Old post but this is how I fixed it... Try throwing this code into a plugin or your functions.php file.

function remove_bad_things(){ ?>
<script>

jQuery('#content-html').click(function(){
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// <![CDATA[','') );
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// ]]>','') );
});

</script>
<?php }

add_action('admin_footer','remove_bad_things');

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 1

Filtering out these tags on saving posts did the trick for me:

function my_filter_cdata( $content ) {
  $content = str_replace( '// <![CDATA[', '', $content );
  $content = str_replace( '// ]]>', '', $content );
  return $content;
}
add_filter( 'content_save_pre', 'my_filter_cdata', 9, 1 );

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 1

Filtering out these tags on saving posts did the trick for me:

function my_filter_cdata( $content ) {
  $content = str_replace( '// <![CDATA[', '', $content );
  $content = str_replace( '// ]]>', '', $content );
  return $content;
}
add_filter( 'content_save_pre', 'my_filter_cdata', 9, 1 );

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 1

$content = str_replace(']]>', ']]&gt;', $content);

Thanks for the help Badri , I found the solution on line 167 by changing code to this : wp-includes\post-template.php line 167 $content = str_replace('<![CDATA[','',$content); $content = str_replace(']]>','',$content); //$content = str_replace(']]>', ']]', $content);

html - Stop WordPress from enclosing script in CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 1

$content = str_replace(']]>', ']]&gt;', $content);

Thanks for the help Badri , I found the solution on line 167 by changing code to this : wp-includes\post-template.php line 167 $content = str_replace('<![CDATA[','',$content); $content = str_replace(']]>','',$content); //$content = str_replace(']]>', ']]', $content);

html - Stop WordPress from enclosing script in CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

$content = str_replace(']]>', ']]&gt;', $content);

Thanks for the help Badri , I found the solution on line 167 by changing code to this : wp-includes\post-template.php line 167 $content = str_replace('<![CDATA[','',$content); $content = str_replace(']]>','',$content); //$content = str_replace(']]>', ']]', $content);

html - Stop WordPress from enclosing script in CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

Much as I hate answering with 'use a plugin' on SO there's a few plugins that allow you to add code via a shortcode. I use an old one called Qoate on my blog (still works fine on 3.4);

Save yourself a load of hassle trying to set it all up and format it yourself (concentrate on writing the code to be displayed rather than the code to display it! :) )

Thanks for the advise. Worked like a charm!

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

Much as I hate answering with 'use a plugin' on SO there's a few plugins that allow you to add code via a shortcode. I use an old one called Qoate on my blog (still works fine on 3.4);

Save yourself a load of hassle trying to set it all up and format it yourself (concentrate on writing the code to be displayed rather than the code to display it! :) )

Thanks for the advise. Worked like a charm!

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

Old post but this is how I fixed it... Try throwing this code into a plugin or your functions.php file.

function remove_bad_things(){ ?>
<script>

jQuery('#content-html').click(function(){
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// <![CDATA[','') );
  jQuery('textarea[name=content]').val( jQuery('textarea[name=content]').val().replace('// ]]>','') );
});

</script>
<?php }

add_action('admin_footer','remove_bad_things');

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

Filtering out these tags on saving posts did the trick for me:

function my_filter_cdata( $content ) {
  $content = str_replace( '// <![CDATA[', '', $content );
  $content = str_replace( '// ]]>', '', $content );
  return $content;
}
add_filter( 'content_save_pre', 'my_filter_cdata', 9, 1 );

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata
Rectangle 27 0

In my case the issue was that Ajax form handler not being called after form submit. Instead it would directly branch to the 'action' parameter given in the form. The basic issue was due to repeated switching of WYSIWYG and HTML editors in the wordpress, somehow the ajax form submit handler was commented out by automatically by inserting ![CDATA[.

The solution is to disable WYSIWYG while editing wordpress posts and delete the ![CDATA[ keyword before the scripts..

HTML form submit not calling Javascript "onsubmit" handler in Wordpres...

javascript html wordpress forms
Rectangle 27 0

Much as I hate answering with 'use a plugin' on SO there's a few plugins that allow you to add code via a shortcode. I use an old one called Qoate on my blog (still works fine on 3.4);

Save yourself a load of hassle trying to set it all up and format it yourself (concentrate on writing the code to be displayed rather than the code to display it! :) )

Thanks for the advise. Worked like a charm!

html - Keep wordpress from adding CDATA - Stack Overflow

html wordpress xhtml cdata