When adding code to a WordPress post, you may find that it gets modified (particularly when using the visual editor). For some years now, a popular plugin of mine, Code Embed, has allowed you a way to achieve this without any such modification. However, the plugin has had many features to it, making it a lot larger from what it first was. And that first release did it just a few lines of code.
So, dusting those lines down, bringing them up to VIP coding standards, here they are for anybody to easily add to their site, for example, via their functions.php
theme file…
How to use?
- Head to the custom fields meta box on your posts page and add a new field.
- Specify the field name as CODEx, where x is a number between 1 and 5 to uniquely identify that code for this post (therefore allowing up to 5 pieces of code to be inserted per post – there’s no reason you can’t expand this number, but I’ve get it to 5 for now).
- The field value should be the code that you wish to embed in your post.
- Once the custom field is saved, in your post simply write
{{CODEx}}
wherever you wish the code to appear (again, replace x with the relevant number).
Talk to me!