How to display[C,C++,JAVA,PYTHON] Code in blogpost

Have you ever excited to write a code in a blog post, but I was excited when I started  the blogging

3 ways to write code in a blogpost

  1. Default editor
  2. WordPress Plugin
  3. Embed code snippet

Default editor

We can write code in WordPress blogpost by using default editor and this is the simplest and the easiest way to do

  1. Go to your WordPress dashboard
  2. Create a new post
  3. Click on the ADD block (+) symbol
  4. Write in search box “code” then
  5. Select formatting <> code option
  6. Copy and paste your code in the write code box

Let us see one code example, how it looks like in blogpost by using the default editor

Addition of number of elements in an array with C

 code Default editor wordpress

WordPress plugin

Let us use a plugin to display code in our blog and the most popular plugins are

(i)Crayon syntax highlighter

(ii) Enlighter – Customizable Syntax Highlighter

Crayon syntax highlighter

Install crayon syntax highlighter by

  1. Go to WordPress dashboard
  2. Click on plugin—->ADD new
  3. Then search for plugin Crayon syntax highlighter
  4. Install and active
  5. Then go the setting of the plugin and select theme option  which you like
  6. And save changes
  7. Create a new post
  8. Click on the ADD block (+) symbol
  9. Write in search box “code” then
  10. Select formatting <> code option
  11. Copy and paste your code in the write code box
crayon syntax highlighter

Let us see code example, how it looks like in blogpost when a plugin is used instead of the default editor

Addition of number of elements in an array with C

post code

Embed code snippet

Do you know? how to embed code snippets in a blog post? and This is a third way of displaying code in WordPress

We have seen how posts code displayed in WordPress by default editor also using WordPress plugin let us see how to display WordPress code snippet by embed method

In order to display WordPress code, we use an online tool called GitHub gist

Step 1

  1. Log in to your GitHub account
  2. Go to GitHub Gist
  3. Write a file for the code
  4. Copy and paste your code in Gist

Step 2

  1. Copy the embed code
  2. And paste in the paragraph of your blog with the edit as Html and
  3. publish
posts code
posts code

let us see how the syntax of the code will look like when we use GitHub Gist to display WordPress code snippets  

Addition of number of elements in an array with C

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.