Posted On May 16, 2023

How to add code in wordpress post?

Ghazal Ehsan 0 comments
Hut Explore >> Programming , Technology >> How to add code in wordpress post?
How to add code in wordpress post?

To add code to a WordPress post, you have a few options depending on your needs and preferences. Here are a few common methods:

1. Using the “Code” Block in the Gutenberg Editor:
– Create or edit a WordPress post.
– In the Gutenberg editor, click on the “+” button to add a new block.
– Search for “Code” or scroll down to find the “Code” block and click on it.
– A new code block will be added to your post. You can now paste your code into the block.
– Adjust the settings or style of the code block as needed.
– Update or publish your post.

2. Using a Syntax Highlighting Plugin:
– Install and activate a syntax highlighting plugin from the WordPress plugin repository. Some popular options include “SyntaxHighlighter Evolved,” “Prism Syntax Highlighter,” or “WP Code Highlight.js.”
– Create or edit a WordPress post.
– Switch to the text editor mode.
– Wrap your code in the appropriate shortcode provided by the plugin. For example, if you’re using SyntaxHighlighter Evolved, you can use `[code language=”php”]your code[/code]` to highlight PHP code.
– Switch back to the visual editor mode to see the highlighted code.
– Update or publish your post.

3. Using HTML Preformatted Text:
– Create or edit a WordPress post.
– Switch to the text editor mode.
– Wrap your code in `

` and `` HTML tags. For example:


Your code goes here

– Switch back to the visual editor mode to see the preformatted code.
– Update or publish your post.

Remember to use the method that best suits your needs and aligns with your WordPress editor. Additionally, ensure that the code is properly formatted and readable for your readers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

WhatsApp launches native Windows app, and new macOS version is on the way

WhatsApp launches native Windows app, and new macOS version is on the way WhatsApp on…

Google to invest up to 1 billion $ in Indian telecom operator Airtel

Google to invest up to 1 billion dollar in Indian telecom operator Airtel. Google will…