Write Code in Wordpress Posts

Digg this

Sometime you might need to add pieces of code like HTML, CSS, PHP, or javascripts in your post and make this code “looks” like code, but “doesn’t behave” like code. WordPress.com changes codes such as <, >, &, “, and ‘ into characters. For example, if you type:

<? php query_posts('p=5'); ?>

It will erased from your post when you save it. Or it will try to turn the codes into character entity codes, which can really mess some things up.
  • To make this WordPress template tag code appear, the code must be converted into character entities:

  • <? php query_posts('p=5'); ?>

  • To Write Code in Your Posts so that it looks like a box of code which may be copied and pasted within other code or template file, you can read this article for more details

  • Further Readings On Writing Code in your Posts

    1)Signatures and Writing Code- Lorelle writes an amazing article on posting code in your WordPress.com blogs, listing the most common character codes (character entities) used in HTML/XHTML, PHP, and other programming languages. Also you need to check her other post “WordPress Plugins That Help You Write Code” sharing some of the WordPress Plugins that help you write code and equations in your blogs.

  • 2)Online Code Converters- There are several online converters that transform the text you type into the standard HTML code that every browser can recognize without altering the character encoding to help you change code into something that WordPress blog can display properly.

Related Posts by Categories



Widget by Scrapur | Scrap Book

0 comments: