doncharisma, don charisma, Wordpress Code Box

How to add a code box in free WordPress blog

Frustratingly, WordPress free blog doesn’t have a code box facility, or not one that I could find. Sometimes it’s handy to put a code box for code snippets or commands to be run a command line, like this

Code:

#!/bin/bash
# rsync script
rsync -avh --exclude="*.bak" /home/user/Documents/ /media/diskid/user_backup/Documents/


Here’s how this is done :

Code:

<table width="400" border="1" cellspacing="0" cellpadding="0" bgcolor="cyan">
<tbody>
<tr>
<th align="left"><code>Code:</code></th>
</tr>
<tr>
<td><code>
#!/bin/bash
# rsync script
rsync -avh --exclude="*.bak" /home/user/Documents/ /media/diskid/user_backup/Documents/
<br class="blank" />
</code></td>
</tr>
</tbody>
</table>

But … Before you put your own code in remember html looks for < and > for tags, so must replace “<” with “&lt;” and “>” with “&gt”, so for instance “<tr>” would become “&lt;tr&gt;”

3 thoughts on “How to add a code box in free WordPress blog

Leave a Reply for Don Charisma

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.