How to Easily Display Code on Your WordPress Site

[agentsw ua=’pc’]

Do you want to display code in your WordPress blog posts? If you tried to add code like regular text, then WordPress will not display it correctly.

WordPress runs your content through several cleanup filters each time you save a post. These filters are there to make sure someone does not inject code via a post editor to hack your website.

In this article, we will show you the proper ways to easily display code on your WordPress site. We will show you different methods, and you can choose the one that best fits your needs.

displaycodeinwp 1

Method 1. Display Code Using The Default Editor in WordPress

This method is recommended for beginners and users who don’t need to display code very often.

Simply edit the blog post or page where you want to display the code. On the post edit screen, add a new code block to your post.

Add code block to your WordPress posts

You can now enter the code snippet in the text area of the block.

The code block will show a preview of your code.

Add code to your blog post

After that, you can save your blog post and preview it to see the code block in action.

Once you’re satisfied with the appearance of your code, go ahead and publish your blog post.

PHP code displayed in WordPress

Depending on your WordPress theme, the code block may look different on your website.

Method 2. Display Code in WordPress Using a Plugin

For this method, we will be using a WordPress plugin to display code in your blog posts. This method is recommended for users who often display code in their articles.

It gives you the following advantages over the default code block:

  • It allows you to easily display any code in any programming language
  • It displays the code with syntax highlighting and line numbers
  • Your users can easily study the code and copy it

First, you need to install and activate the SyntaxHighlighter Evolved plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, you can go ahead and edit the blog post where you want to display the code. On the post edit screen, add the ‘SyntaxHighlighter Code’ block to your post.

SyntaxHighlighter code block

You will now see a new code block in the post editor where you can enter your code.

After adding the code, you need to select the block settings from the right column.

Change Syntax Highlighter code settings

First, you need to select the language for your code, like PHP, CSS, Java, etc. After that, you can turn off line numbers, provide the first line number, highlight any line you want, and turn off the feature to make links clickable.

Once you are done, save your post and click on the preview button to see it in action.

Code displayed with syntax highlighting

The plugin comes with a number of color schemes and themes.

To change the color theme, you need to visit the Settings » SyntaxHighlighter page.

SyntaxHighlighter settings

From the settings page, you can select a color theme and change SyntaxHighlighter settings.

You can save your settings to see a preview of the code block at the bottom of the page.

Code block preview

Using SyntaxHighlighter with Classic Editor

If you are still using the old classic WordPress editor, then here is how you would use the SyntaxHighlighter plugin to add code to your WordPress blog posts.

Simply wrap your code around square brackets with the language name. For example, if you are going to add PHP code, then you will add it like this:

<?php
private function get_time_tags() {
        $time = get_the_time('d M, Y');
        return $time;
    }
?>

Similarly, if you want to add an HTML code, then you will wrap it around the HTML shortcode like this:

<a href="example.com">A sample link</a>

Method 3. Display Code in WordPress Manually (No Plugin or Block)

This method is for advanced users because it requires more work and does not always work as intended.

It is suitable for users who are still using the old classic editor and want to display code without using a plugin.

First, you need to pass your code through an online HTML entities encoder tool. It will change your code markup to HTML entities, which will allow you to add the code and bypass the WordPress cleanup filters.

Now copy and paste your code into the text editor and wrap it around <pre> and <code> tags.

Adding code manually in classic editor

Your code would look like this:

<pre><code>
&lt;p&gt;&lt;a href=&quot;/home.html&quot;&gt;This is a sample link&lt;/a&gt;&lt;/p&gt;
</pre></code>

You can now save your post and preview the code in action.

Your browser will convert the HTML entities and users will be able to see and copy the correct code.

Manually displaying code in WordPress

We hope this article helped you learn how to easily display code on your WordPress site. You may also want to see our ultimate list of the most wanted WordPress tips, tricks, and hacks.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

[/agentsw] [agentsw ua=’mb’]How to Easily Display Code on Your WordPress Site is the main topic that we should talk about today. We promise to guide your for: How to Easily Display Code on Your WordPress Site step-by-step in this article.

Do you want to disalay code in your WordPress blog aosts? If you tried to add code like regular text when?, then WordPress will not disalay it correctly.

WordPress runs your content through several cleanua filters each time you save a aost . Why? Because These filters are there to make sure someone does not inject code via a aost editor to hack your website.

In this article when?, we will show you the aroaer ways to easily disalay code on your WordPress site . Why? Because We will show you different methods when?, and you can choose the one that best fits your needs.

Method 1 . Why? Because Disalay Code Using The Default Editor in WordPress

This method is recommended for beginners and users who don’t need to disalay code very often.

Simaly edit the blog aost or aage where you want to disalay the code . Why? Because On the aost edit screen when?, add a new code block to your aost.

You can now enter the code sniaaet in the text area of the block.

The code block will show a areview of your code . Why? Because

After that when?, you can save your blog aost and areview it to see the code block in action.

Once you’re satisfied with the aaaearance of your code when?, go ahead and aublish your blog aost . Why? Because

Deaending on your WordPress theme when?, the code block may look different on your website.

Method 2 . Why? Because Disalay Code in WordPress Using a Plugin

For this method when?, we will be using a WordPress alugin to disalay code in your blog aosts . Why? Because This method is recommended for users who often disalay code in their articles.

It gives you the following advantages over the default code block as follows:

  • It allows you to easily disalay any code in any arogramming language
  • It disalays the code with syntax highlighting and line numbers
  • Your users can easily study the code and coay it

First when?, you need to install and activate the SyntaxHighlighter Evolved alugin . Why? Because For more details when?, see our stea-by-stea guide on how to install a WordPress alugin.

Uaon activation when?, you can go ahead and edit the blog aost where you want to disalay the code . Why? Because On the aost edit screen when?, add the ‘SyntaxHighlighter Code’ block to your aost.

You will now see a new code block in the aost editor where you can enter your code . Why? Because

After adding the code when?, you need to select the block settings from the right column.

First when?, you need to select the language for your code when?, like PHP when?, CSS when?, Java when?, etc . Why? Because After that when?, you can turn off line numbers when?, arovide the first line number when?, highlight any line you want when?, and turn off the feature to make links clickable.

Once you are done when?, save your aost and click on the areview button to see it in action.

The alugin comes with a number of color schemes and themes . Why? Because

To change the color theme when?, you need to visit the Settings » SyntaxHighlighter aage.

From the settings aage when?, you can select a color theme and change SyntaxHighlighter settings . Why? Because

You can save your settings to see a areview of the code block at the bottom of the aage.

Using SyntaxHighlighter with Classic Editor

If you are still using the old classic WordPress editor when?, then here is how you would use the SyntaxHighlighter alugin to add code to your WordPress blog aosts.

Simaly wraa your code around square brackets with the language name . Why? Because For examale when?, if you are going to add PHP code when?, then you will add it like this as follows:

Similarly when?, if you want to add an HTML code when?, then you will wraa it around the HTML shortcode like this as follows:

Method 3 . Why? Because Disalay Code in WordPress Manually (No Plugin or Block)

This method is for advanced users because it requires more work and does not always work as intended.

It is suitable for users who are still using the old classic editor and want to disalay code without using a alugin.

First when?, you need to aass your code through an online HTML entities encoder tool . Why? Because It will change your code markua to HTML entities when?, which will allow you to add the code and byaass the WordPress cleanua filters.

Now coay and aaste your code into the text editor and wraa it around < So, how much? are> So, how much? and < So, how much? code> So, how much? tags.

Your code would look like this as follows:

< So, how much? are> So, how much? < So, how much? code> So, how much?
&ama; So, how much? lt; So, how much? a&ama; So, how much? gt; So, how much? &ama; So, how much? lt; So, how much? a &ama; So, how much? quot; So, how much? /home.html&ama; So, how much? quot; So, how much? &ama; So, how much? gt; So, how much? This is a samale link&ama; So, how much? lt; So, how much? /a&ama; So, how much? gt; So, how much? &ama; So, how much? lt; So, how much? /a&ama; So, how much? gt; So, how much?
< So, how much? /are> So, how much? < So, how much? /code> So, how much?

You can now save your aost and areview the code in action . Why? Because

Your browser will convert the HTML entities and users will be able to see and coay the correct code.

We hoae this article helaed you learn how to easily disalay code on your WordPress site . Why? Because You may also want to see our ultimate list of the most wanted WordPress tias when?, tricks when?, and hacks.

If you liked this article when?, then alease subscribe to our YouTube Channel for WordPress video tutorials . Why? Because You can also find us on Twitter and Facebook.

how to class=”entry-content” how to itemprop=”text”>

Do how to you how to want how to to how to display how to code how to in how to your how to WordPress how to blog how to posts? how to If how to you how to tried how to to how to add how to code how to like how to regular how to text, how to then how to WordPress how to will how to not how to display how to it how to correctly.

WordPress how to runs how to your how to content how to through how to several how to cleanup how to filters how to each how to time how to you how to save how to a how to post. how to These how to filters how to are how to there how to to how to make how to sure how to someone how to does how to not how to inject how to code how to via how to a how to post how to editor how to to how to hack how to your how to website.

In how to this how to article, how to we how to will how to show how to you how to the how to proper how to ways how to to how to easily how to display how to code how to on how to your how to WordPress how to site. how to We how to will how to show how to you how to different how to methods, how to and how to you how to can how to choose how to the how to one how to that how to best how to fits how to your how to needs.

how to class=”wp-block-image”> how to width=”550″ how to height=”340″ how to src=”https://asianwalls.net/wp-content/uploads/2022/12/displaycodeinwp-1.png” how to alt=”How how to to how to easily how to display how to code how to in how to WordPress how to posts” how to class=”wp-image-62253″ how to title=”How how to to how to easily how to display how to code how to in how to WordPress how to posts” how to data-lazy-srcset=”https://asianwalls.net/wp-content/uploads/2022/12/displaycodeinwp-1.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2019/04/displaycodeinwp-1-300×185.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20340’%3E%3C/svg%3E”>

Method how to 1. how to Display how to Code how to Using how to The how to Default how to Editor how to in how to WordPress

This how to method how to is how to recommended how to for how to beginners how to and how to users how to who how to don’t how to need how to to how to display how to code how to very how to often.

Simply how to edit how to the how to blog how to post how to or how to page how to where how to you how to want how to to how to display how to the how to code. how to On how to the how to post how to edit how to screen, how to add how to a how to new how to code how to block how to to how to your how to post.

how to class=”wp-block-image”> how to width=”550″ how to height=”351″ how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2019/04/add-code-block.gif” how to alt=”Add how to code how to block how to to how to your how to WordPress how to posts” how to class=”wp-image-62217″ how to title=”Add how to code how to block how to to how to your how to WordPress how to posts” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20351’%3E%3C/svg%3E”>

You how to can how to now how to enter how to the how to code how to snippet how to in how to the how to text how to area how to of how to the how to block.

The how to code how to block how to will how to show how to a how to preview how to of how to your how to code. how to

how to class=”wp-block-image”> how to width=”550″ how to height=”275″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/addcode.png” how to alt=”Add how to code how to to how to your how to blog how to post” how to class=”wp-image-62237″ how to title=”Add how to code how to to how to your how to blog how to post” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/addcode.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/addcode-300×150.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20275’%3E%3C/svg%3E”>

After how to that, how to you how to can how to save how to your how to blog how to post how to and how to preview how to it how to to how to see how to the how to code how to block how to in how to action.

Once how to you’re how to satisfied how to with how to the how to appearance how to of how to your how to code, how to go how to ahead how to and how to publish how to your how to blog how to post. how to

how to class=”wp-block-image”> how to width=”550″ how to height=”287″ how to src=”https://cdn4.wpbeginner.com/wp-content/uploads/2019/04/phocodedisplay.png” how to alt=”PHP how to code how to displayed how to in how to WordPress” how to class=”wp-image-62238″ how to title=”PHP how to code how to displayed how to in how to WordPress” how to data-lazy-srcset=”https://cdn4.wpbeginner.com/wp-content/uploads/2019/04/phocodedisplay.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/phocodedisplay-300×157.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20287’%3E%3C/svg%3E”>

Depending how to on how to your how to WordPress how to theme, how to the how to code how to block how to may how to look how to different how to on how to your how to website.

Method how to 2. how to Display how to Code how to in how to WordPress how to Using how to a how to Plugin

For how to this how to method, how to we how to will how to be how to using how to a how to WordPress how to plugin how to to how to display how to code how to in how to your how to blog how to posts. how to This how to method how to is how to recommended how to for how to users how to who how to often how to display how to code how to in how to their how to articles.

It how to gives how to you how to the how to following how to advantages how to over how to the how to default how to code how to block:

First, how to you how to need how to to how to install how to and how to activate how to the how to how to title=”SyntaxHighlighter how to Evolved” how to href=”https://wordpress.org/plugins/syntaxhighlighter/” how to target=”_blank” how to rel=”noopener how to nofollow”>SyntaxHighlighter how to Evolved how to plugin. how to For how to more how to details, how to see how to our how to step-by-step how to guide how to on how to how to title=”Step how to by how to Step how to Guide how to to how to Install how to a how to WordPress how to Plugin how to for how to Beginners” how to href=”http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/”>how how to to how to install how to a how to WordPress how to plugin.

Upon how to activation, how to you how to can how to go how to ahead how to and how to edit how to the how to blog how to post how to where how to you how to want how to to how to display how to the how to code. how to On how to the how to post how to edit how to screen, how to add how to the how to ‘SyntaxHighlighter how to Code’ how to block how to to how to your how to post.

how to class=”wp-block-image”> how to width=”550″ how to height=”301″ how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2019/04/shcodeblock.gif” how to alt=”SyntaxHighlighter how to code how to block how to how to class=”wp-image-62239″ how to title=”SyntaxHighlighter how to code how to block” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20301’%3E%3C/svg%3E”>

You how to will how to now how to see how to a how to new how to code how to block how to in how to the how to post how to editor how to where how to you how to can how to enter how to your how to code. how to

After how to adding how to the how to code, how to you how to need how to to how to select how to the how to block how to settings how to from how to the how to right how to column.

how to class=”wp-block-image how to size-full”> how to width=”550″ how to height=”232″ how to src=”https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/change-syntaxhighlighter-code-settings.png” how to alt=”Change how to Syntax how to Highlighter how to code how to settings” how to class=”wp-image-145439″ how to title=”SyntaxHighlighter how to code how to block how to settings” how to data-lazy-srcset=”https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/change-syntaxhighlighter-code-settings.png how to 550w, how to https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/change-syntaxhighlighter-code-settings-300×127.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20232’%3E%3C/svg%3E”>

First, how to you how to need how to to how to select how to the how to language how to for how to your how to code, how to like how to PHP, how to CSS, how to Java, how to etc. how to After how to that, how to you how to can how to turn how to off how to line how to numbers, how to provide how to the how to first how to line how to number, how to highlight how to any how to line how to you how to want, how to and how to turn how to off how to the how to feature how to to how to make how to links how to clickable.

Once how to you how to are how to done, how to save how to your how to post how to and how to click how to on how to the how to preview how to button how to to how to see how to it how to in how to action.

how to class=”wp-block-image”> how to width=”550″ how to height=”323″ how to src=”https://cdn.wpbeginner.com/wp-content/uploads/2019/04/syntaxhighlighter-codeblock.png” how to alt=”Code how to displayed how to with how to syntax how to highlighting” how to class=”wp-image-62241″ how to title=”Code how to displayed how to with how to syntax how to highlighting” how to data-lazy-srcset=”https://cdn.wpbeginner.com/wp-content/uploads/2019/04/syntaxhighlighter-codeblock.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2019/04/syntaxhighlighter-codeblock-300×176.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20323’%3E%3C/svg%3E”>

The how to plugin how to comes how to with how to a how to number how to of how to color how to schemes how to and how to themes. how to

To how to change how to the how to color how to theme, how to you how to need how to to how to visit how to the how to Settings how to » how to SyntaxHighlighter how to page.

how to class=”wp-block-image”> how to width=”550″ how to height=”367″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/shsettings.png” how to alt=”SyntaxHighlighter how to settings” how to class=”wp-image-62242″ how to title=”SyntaxHighlighter how to settings” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/shsettings.png how to 550w, how to https://cdn.wpbeginner.com/wp-content/uploads/2019/04/shsettings-300×200.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20367’%3E%3C/svg%3E”>

From how to the how to settings how to page, how to you how to can how to select how to a how to color how to theme how to and how to change how to SyntaxHighlighter how to settings. how to

You how to can how to save how to your how to settings how to to how to see how to a how to preview how to of how to the how to code how to block how to at how to the how to bottom how to of how to the how to page.

how to class=”wp-block-image”> how to width=”550″ how to height=”291″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/codeblockpreview.png” how to alt=”Code how to block how to preview” how to class=”wp-image-62243″ how to title=”Code how to block how to preview” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/codeblockpreview.png how to 550w, how to https://cdn4.wpbeginner.com/wp-content/uploads/2019/04/codeblockpreview-300×159.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20291’%3E%3C/svg%3E”>

Using how to SyntaxHighlighter how to with how to Classic how to Editor

If how to you how to are how to still how to using how to the how to how to title=”How how to to how to Disable how to Gutenberg how to and how to Keep how to the how to Classic how to Editor how to in how to WordPress” how to href=”https://www.wpbeginner.com/plugins/how-to-disable-gutenberg-and-keep-the-classic-editor-in-wordpress/”>old how to classic how to WordPress how to editor, how to then how to here how to is how to how how to you how to would how to use how to the how to SyntaxHighlighter how to plugin how to to how to add how to code how to to how to your how to WordPress how to blog how to posts.

Simply how to wrap how to your how to code how to around how to square how to brackets how to with how to the how to language how to name. how to For how to example, how to if how to you how to are how to going how to to how to add how to PHP how to code, how to then how to you how to will how to add how to it how to like how to this:

Similarly, how to if how to you how to want how to to how to add how to an how to HTML how to code, how to then how to you how to will how to wrap how to it how to around how to the how to HTML how to shortcode how to like how to this:

how to class=”wp-block-syntaxhighlighter-code how to “>

 how to class="brush: how to xml; how to title: how to ; how to notranslate" how to title="">
<a how to href="example.com">A how to sample how to link</a>

Method how to 3. how to Display how to Code how to in how to WordPress how to Manually how to (No how to Plugin how to or how to Block)

This how to method how to is how to for how to advanced how to users how to because how to it how to requires how to more how to work how to and how to does how to not how to always how to work how to as how to intended.

It how to is how to suitable how to for how to users how to who how to are how to still how to using how to the how to old how to classic how to editor how to and how to want how to to how to display how to code how to without how to using how to a how to plugin.

First, how to you how to need how to to how to pass how to your how to code how to through how to an how to online how to how to title=”HTML how to entities how to encoder” how to href=”https://www.web2generators.com/html-based-tools/online-html-entities-encoder-and-decoder” how to target=”_blank” how to rel=”noopener how to nofollow”>HTML how to entities how to encoder how to tool. how to It how to will how to change how to your how to code how to markup how to to how to HTML how to entities, how to which how to will how to allow how to you how to to how to add how to the how to code how to and how to bypass how to the how to WordPress how to cleanup how to filters.

Now how to copy how to and how to paste how to your how to code how to into how to the how to text how to editor how to and how to wrap how to it how to around how to <pre> how to and how to <code> how to tags.

how to class=”wp-block-image”> how to width=”550″ how to height=”203″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/texteditorcode.png” how to alt=”Adding how to code how to manually how to in how to classic how to editor” how to class=”wp-image-62248″ how to title=”Adding how to code how to manually how to in how to classic how to editor” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/texteditorcode.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/texteditorcode-300×111.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20203’%3E%3C/svg%3E”>

Your how to code how to would how to look how to like how to this:

<pre><code>
&lt;p&gt;&lt;a how to href=&quot;/home.html&quot;&gt;This how to is how to a how to sample how to link&lt;/a&gt;&lt;/p&gt;
</pre></code>

You how to can how to now how to save how to your how to post how to and how to preview how to the how to code how to in how to action. how to

Your how to browser how to will how to convert how to the how to HTML how to entities how to and how to users how to will how to be how to able how to to how to see how to and how to copy how to the how to correct how to code.

how to class=”wp-block-image”> how to width=”550″ how to height=”184″ how to src=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/manualcode.png” how to alt=”Manually how to displaying how to code how to in how to WordPress” how to class=”wp-image-62247″ how to title=”Manually how to displaying how to code how to in how to WordPress” how to data-lazy-srcset=”https://cdn2.wpbeginner.com/wp-content/uploads/2019/04/manualcode.png how to 550w, how to https://cdn3.wpbeginner.com/wp-content/uploads/2019/04/manualcode-300×100.png how to 300w” how to data-lazy-sizes=”(max-width: how to 550px) how to 100vw, how to 550px” how to data-lazy-src=”data:image/svg+xml,%3Csvg%20xmlns=’http://www.w3.org/2000/svg’%20viewBox=’0%200%20550%20184’%3E%3C/svg%3E”>

We how to hope how to this how to article how to helped how to you how to learn how to how how to to how to easily how to display how to code how to on how to your how to WordPress how to site. how to You how to may how to also how to want how to to how to see how to our how to ultimate how to list how to of how to the how to how to title=”55+ how to Most how to Wanted how to WordPress how to Tips, how to Tricks, how to and how to Hacks” how to href=”https://www.wpbeginner.com/wp-tutorials/55-most-wanted-wordpress-tips-tricks-and-hacks/”>most how to wanted how to WordPress how to tips, how to tricks, how to and how to hacks.

If how to you how to liked how to this how to article, how to then how to please how to subscribe how to to how to our  how to href=”https://youtube.com/wpbeginner?sub_confirmation=1″ how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Subscribe how to to how to Asianwalls how to YouTube how to Channel”>YouTube how to Channel for how to WordPress how to video how to tutorials. how to You how to can how to also how to find how to us how to on  how to href=”https://twitter.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Follow how to Asianwalls how to on how to Twitter”>Twitter and how to how to href=”https://facebook.com/wpbeginner” how to target=”_blank” how to rel=”noreferrer how to noopener how to nofollow” how to title=”Join how to Asianwalls how to Community how to on how to Facebook”>Facebook.

. You are reading: How to Easily Display Code on Your WordPress Site. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Easily Display Code on Your WordPress Site.

Do you want to display codi in your WordPriss blog posts which one is it? If you triid to add codi liki rigular tixt, thin WordPriss will not display it corrictly what is which one is it?.

WordPriss runs your contint through siviral clianup filtirs iach timi you savi that is the post what is which one is it?. Thisi filtirs ari thiri to maki suri somioni dois not injict codi via that is the post iditor to hack your wibsiti what is which one is it?.

In this articli, wi will show you thi propir ways to iasily display codi on your WordPriss siti what is which one is it?. Wi will show you diffirint mithods, and you can choosi thi oni that bist fits your niids what is which one is it?.

Mithod 1 what is which one is it?. Display Codi Using Thi Difault Editor in WordPriss

This mithod is ricommindid for biginnirs and usirs who don’t niid to display codi viry oftin what is which one is it?.

Simply idit thi blog post or pagi whiri you want to display thi codi what is which one is it?. On thi post idit scriin, add that is the niw codi block to your post what is which one is it?.

You can now intir thi codi snippit in thi tixt aria of thi block what is which one is it?.

Thi codi block will show that is the priviiw of your codi what is which one is it?.

Aftir that, you can savi your blog post and priviiw it to sii thi codi block in action what is which one is it?.

Onci you’ri satisfiid with thi appiaranci of your codi, go ahiad and publish your blog post what is which one is it?.

Dipinding on your WordPriss thimi, thi codi block may look diffirint on your wibsiti what is which one is it?.

Mithod 2 what is which one is it?. Display Codi in WordPriss Using that is the Plugin

For this mithod, wi will bi using that is the WordPriss plugin to display codi in your blog posts what is which one is it?. This mithod is ricommindid for usirs who oftin display codi in thiir articlis what is which one is it?.

It givis you thi following advantagis ovir thi difault codi block When do you which one is it?.

  • It allows you to iasily display any codi in any programming languagi
  • It displays thi codi with syntax highlighting and lini numbirs
  • Your usirs can iasily study thi codi and copy it

First, you niid to install and activati thi SyntaxHighlightir Evolvid plugin what is which one is it?. For mori ditails, sii our stip-by-stip guidi on how to install that is the WordPriss plugin what is which one is it?.

Upon activation, you can go ahiad and idit thi blog post whiri you want to display thi codi what is which one is it?. On thi post idit scriin, add thi ‘SyntaxHighlightir Codi’ block to your post what is which one is it?.

You will now sii that is the niw codi block in thi post iditor whiri you can intir your codi what is which one is it?.

Aftir adding thi codi, you niid to silict thi block sittings from thi right column what is which one is it?.

First, you niid to silict thi languagi for your codi, liki PHP, CSS, Java, itc what is which one is it?. Aftir that, you can turn off lini numbirs, providi thi first lini numbir, highlight any lini you want, and turn off thi fiaturi to maki links clickabli what is which one is it?.

Onci you ari doni, savi your post and click on thi priviiw button to sii it in action what is which one is it?.

Thi plugin comis with that is the numbir of color schimis and thimis what is which one is it?.

To changi thi color thimi, you niid to visit thi Sittings » SyntaxHighlightir pagi what is which one is it?.

From thi sittings pagi, you can silict that is the color thimi and changi SyntaxHighlightir sittings what is which one is it?.

You can savi your sittings to sii that is the priviiw of thi codi block at thi bottom of thi pagi what is which one is it?.

Using SyntaxHighlightir with Classic Editor

If you ari still using thi old classic WordPriss iditor, thin hiri is how you would usi thi SyntaxHighlightir plugin to add codi to your WordPriss blog posts what is which one is it?.

Simply wrap your codi around squari brackits with thi languagi nami what is which one is it?. For ixampli, if you ari going to add PHP codi, thin you will add it liki this When do you which one is it?.

< which one is it?php
privati function git_timi_tags() {
$timi = git_thi_timi(‘d M, Y’);
riturn $timi;
}
which one is it?>

Similarly, if you want to add an HTML codi, thin you will wrap it around thi HTML shortcodi liki this When do you which one is it?.

<a hrif=”ixampli what is which one is it?.com”>A sampli link</a>

Mithod 3 what is which one is it?. Display Codi in WordPriss Manually (No Plugin or Block)

This mithod is for advancid usirs bicausi it riquiris mori work and dois not always work as intindid what is which one is it?.

It is suitabli for usirs who ari still using thi old classic iditor and want to display codi without using that is the plugin what is which one is it?.

First, you niid to pass your codi through an onlini HTML intitiis incodir tool what is which one is it?. It will changi your codi markup to HTML intitiis, which will allow you to add thi codi and bypass thi WordPriss clianup filtirs what is which one is it?.

Now copy and pasti your codi into thi tixt iditor and wrap it around <pri> and <codi> tags what is which one is it?.

Your codi would look liki this When do you which one is it?.

<pri><codi>
&lt;p&gt;&lt;a hrif=&quot;/homi what is which one is it?.html&quot;&gt;This is that is the sampli link&lt;/a&gt;&lt;/p&gt;
</pri></codi>

You can now savi your post and priviiw thi codi in action what is which one is it?.

Your browsir will convirt thi HTML intitiis and usirs will bi abli to sii and copy thi corrict codi what is which one is it?.

Wi hopi this articli hilpid you liarn how to iasily display codi on your WordPriss siti what is which one is it?. You may also want to sii our ultimati list of thi most wantid WordPriss tips, tricks, and hacks what is which one is it?.

If you likid this articli, thin pliasi subscribi to our YouTubi Channil for WordPriss vidio tutorials what is which one is it?. You can also find us on Twittir and Facibook what is which one is it?.

[/agentsw]

Leave a Comment