If you a blogger or a WordPress developer then you would be definitely using plugins like syntaxhighlighter, crayon-syntax-highlighter, etc., for highlighting syntax in WordPress. Although these plugins are helping your visitors it might slow down your website. So, go ahead and get rid of them because there is an easy way to highlight syntax in WordPress.
By using GitHub Gist (a repository for snippets) you can easily highlight syntax in your WordPress posts. Still confused? Follow the tutorial given here for using GitHub Gist as a syntax highlighter in WordPress.
Tutorial To Highlight Syntax In WordPress Using GitHub Gist:
1) To get started, go to GitHub Gist and create an account by clicking on “Signup for a GitHub Account“.
2) Once you have signed up for an account, visit the homepage of “GitHub Gist“.
3) Now you will need to create a “Gist” for your snippet. For that, first enter your snippet code description in the “Gist Description” field.
4) Next, you will need to enter a name for your gist along with the file extension type. For example, if you are adding a “.php” code in your gist, you can name your gist as “code.php“.
5) Now add your code in the “code” box. Once done, click on “Create Public Gist” as you will be embedding it in your WordPress website for showcasing the code.
6) Once your gist is created, you can get the embed code as shown in the screenshot below.
7) Now copy the embed code and paste it in your WordPress post or page using the “Text Editor” mode.
That’s it. Now your code will be visible to all your visitors and you have done it without using a syntax highlighter plugin for WordPress.
By using GitHub gist, you can showcase all kind of codes to your WordPress website visitors as it supports all programming languages.
If you encounter any issues while following this tutorial, do let me know via comments.