Have you ever tried to put a snippet of HTML/PHP/etc in a tutorial you were writing? The best way is not entirely obvious.
Many will recommend using a plugin for the simple act of displaying code snippets. I recommend, instead, doing it manually.Â Here’s what you need to do:
Note: I assume you are using the WYSIWYG “visual editor”. If you’re using the other one, the steps will be similar, but there may be be some differences. If you’re not using the visual editor, then chances are you already know how do this.
- Open your preferred text editor.
- Write your code snippet in it.
- Use the Replace tool to change every instance of ” to ". Do the same with angle brackets, and any other symbols that need to be replaced with character entities. Technically, you can just paste everything into the WordPress WYSIWYG editor (and it will convert everything), but you will still need to replace the quote marks with "s.
- Copy and paste the code into the WordPress editor.
- Switch to the “Code” tab, and put some <code> tags around your pasted snippet.
That’s it. Do you really need a plugin for that?