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 “<” and “>” with “>”, so for instance “<tr>” would become “<tr>”
WordPress.com actually has a shortcode for it. Did you look in the support docs?
Hi there, just tested out the code from the support docs and yes code can be done like that AND has line numbers, yay! … awesome, I feel another blog post coming on …
Thanks for your help and good luck with your blog:)
Cheers
Don Charisma
https://doncharisma.wordpress.com