WordPress is an excellent blogging platform, we know that already. However, when it comes to including custom codes, WordPress does not provide any native option. For that purpose, you will need custom code plugins. These plugins let you do everything including inserting codes into the posts, pages or the functions.php file, highlight code, add code to a specific location of your website etc.
In today’s post, I will discuss about the 5 most popular WordPress plugins for adding codes to your WordPress website. Let’s start with Hana Code Insert.
Once you have installed and activated the plugin, go to Settings > Hana Code Insert from your website dashboard. On that page, you will find a textarea for the custom code. If you want to change the size of the textarea, you can do so by changing the columns and rows values from the ‘Settings’ section.
By default, you will get separate shortcodes for each code block you save. You can also create custom shortcode in the ‘Custom Short Code format’ section. And if you want to run PHP code, check the ‘Enable PHP Execution’ box.
In order to create a new code block, provide a title in the ‘New Entry Name’ field and paste the code in the textarea. Click ‘Create New Entry’ to save the code. You will find all of your saved codes in the ‘Edit Existing Entries’ section. To insert a code block, copy the shortcode and paste it into the page or post body.
In order to add a new code block, go to Code Insert > Add New from your website dashboard. Provide a short description; choose the location for the code. If you select ‘Widget’ as the location, then you have to provide the widget title too.
If you are using multiple codes for a same location, then you can prioritize them. You will also find options to include or exclude the code in specific pages. ‘Hide from user’ lets you hide the code from specific types of visitors.
To view all of your saved codes, go to Code Insert > Inserts. You will find all the codes listed there. Hovering over a code block will reveal two additional options – Deactivate and Delete.
This plugin does what it sounds like. It highlights the code inserted into your posts or pages. The highlighting process is as simple as adding <pre> before the code and </pre> after the code. You will also get a button which could be used to add these signs. As the plugin recognizes all the commonly used languages, you don’t have to declare the language name specifically.
After installing and activating the theme, go to the post editor. Switch to the ‘Text’ mode if you want to use the button. Once you are in the text mode, click the ‘WP-Code-Highlight’ button once to insert the <pre> tag and again to insert the </pre> tag. You will have to put your code between these two tags.
In order to change the plugin settings, go to Settings > WP Code Highlight from your website dashboard. From that page, you can disable the button, choose a different highlight theme for the codes, enable line numbers etc.
In order to add a new code block, go to Settings > Easy Code Placement from your website dashboard. Click ‘Add New Code’. In the next page, provide a name for the code. Don’t include any white space in the name. Otherwise, it will return an error. Then, provide your code in the ‘Code’ field. Set the status of the code and finally, click ‘Add’.
You will find all of your codes in the Settings > Easy Code Placement page. Each code will be accompanied by a shortcode and some options to activate or deactivate the code, alignment status, edit and delete links. To use any code, copy the shortcode and paste it into the post or page.
Unlike other plugins of this list, Code Snippets does not allow you to add code blocks into the posts or pages. Rather, this plugin provides a simple and easy way of inserting code snippets in your WordPress website. A snippet is a small PHP code block that helps you to include additional features to WordPress.
While you had to include the code snippet into the functions.php file, Code Snippets saves you from that hassle. By using Code Snippets, you will get a graphical interface which will work exactly as if the snippets were included in your functions.php file. Additionally, you will find some useful options to manage your snippets.
Once you activate the plugin, it will create a new menu item titled ‘Snippets’ in your dashboard. To add a new snippet, go to Snippets > Add New. Provide a title for the snippet, then paste the code and provide a description about the snippet. Finally, click ‘Save Changes and Activate’ to activate the snippet instantly. Alternatively, you can just save the snippet and activate it later.
To view all of your snippets, go to Snippets > Manage. On that page, you will find all of your snippets listed. Hovering over any snippet will reveal links to deactivate, edit, export or delete the snippet.
I hope this post helped you in finding out the custom code plugin you are looking for. However, are you using any of them already? If yes, then please share your experience with us. Or if you think I have missed an obvious one here, let me know that too. I will be glad to take a look at your favorite plugin.
- How to Display WordPress Login Form in the Sidebar - April 17, 2015
- How to Show Posts from Certain Categories in WordPress SideBar - April 4, 2015
- 5 Best Custom Code Plugins for WordPress - March 10, 2015