I have a blog that contains source code on some posts. I've discovered that some posts don't accept the source code and I get variously a Server 500 error or a 403 error. I can only assume there is some protection mechanism in Wordpress that sees the source code and rejects it. However, as my hosting doesn't seem to have any logging enabled I cannot see what is wrong with it (assuming, of course, I'm looking in the right place for a log - which I may not be. I've only just migrated my blog and I'm still learning the technical detail about how WordPress works yet.)

I've narrowed it down to two types of source code:

  • SQL code
  • Razor (the new view engine that arrived with ASP.NET MVC 3)

I've found a work around for getting these posts in to WordPress (Uss the Wordpress RSS Import plugin and copy my post in to an artificial RSS feed file which I import). This is rather unwieldy and I frequently find typos so need to update posts. The importer only ever creates new posts so I can't correct any errors.

Any ideas about how to get posts with source code into Wordpress? I'm using Windows Live Writer to create and publish posts, but as a work around for problematic posts I can always copy and paste the raw HTML then edit directly in the admin pages in Wordpress, but I get the same issue.

Any help much appreciated.

  • did you wrap them inside <pre> tags?
    – kaiser
    May 12, 2011 at 18:23
  • Yes. That is not the issue. The issue is that sometimes with certain types of source code it simply fails with a Server 500 or 403 error. If I take out the source code, the blog post publishes fine, however, it is now a blog post without the required example code to demonstrate my point. In once case I slowly added the source code back in until it failed somewhere around the addition of "NVARCHAR(50)". Sometimes I can use HTML entities so it doesn't look the same although it renders the same.... but that doesn't always work. May 12, 2011 at 21:02
  • 1
    Can you post a sample of something that makes the publish fail? I'll give it a go in one of my test sites.
    – anu
    May 13, 2011 at 13:11

1 Answer 1


From a look at /wp-includes/default-filters.php:

Maybe one of the following filters is causing the problem. I'd try to remove_filter() them and see what happens:

add_filter( 'the_content', 'wptexturize'        );
add_filter( 'the_content', 'convert_smilies'    );
add_filter( 'the_content', 'convert_chars'      );
add_filter( 'the_content', 'wpautop'            );
add_filter( 'the_content', 'shortcode_unautop'  );
add_filter( 'the_content', 'prepend_attachment' );

If this doesn't help, we'll need another workaround.

  • @ColinMackay Calling you to know if you tried this, and if it worked. If it did, "mark" it as the answer.
    – its_me
    Jul 9, 2012 at 12:24

Your Answer

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

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