fbpx

Get the Official WPSaviour App Now!

Best WordPress PluginsBlog

Embed PHP, CSS Codes in WordPress with SyntaxHighlighter Evolved Plugin

I have been writing about WordPress and lots of Thesis customization posts here at WPSaviour from long. Earlier I used to use an addon for Windows Live writer which made my work easier to embed code in WordPress post. Though later on that addon was not updated and therefore I had to look for another options to show codes in my WordPress posts.

Here I’m sharing about a useful WordPress plugin call SyntaxHighlighter Evolved plugin which will make your work easier to embed code in your blog post. Specially if you write a Blog on coding, this is the plugin which will make your work easier. This plugin comes with decent settings options like different color themes for highlighting codes, line numbers on or off, toolbar for easy copying and so on. You can access the settings from Settings > Syntax Highlighter

How to Add codes using SyntexHighlighter WordPress plugin?

Embedding code using this plugin is very easy. All you need to do is add the shotcodes depending upon the code. You can find the reference from the setting page of this plugin: For example. use

Here are codes which are added by using this plugin : You don’t need to add the shortcode in HTML mode, you can use visual mode in post editor to embed codes using this plugin.

Embeding css code by adding the code between CSS shortcode:

[css]
.custom #header_area {display:none;}
.custom #header {padding: 0;}
.custom #page {padding:5px 20px;}
[/css]

Embeding Php code between php Shortcode:

[php]
//Auto Thumbnail Code
function joe_auto_thumb(){
global $post, $posts;
$first_img = ”;
ob_start();
ob_end_clean();
$output = preg_match_all(‘//i’, $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){return $first_img= “https://www.WPSaviour.com/wp-content/uploads/2011/03/sml-125×125-default.jpg”;}
else {return $first_img;}
}
add_action(‘init’, ‘WPSaviour_auto_thumb’);
[/php]

Since this plugin is authored by Automattic (WordPress parent company), I can recommend this plugin as one of the best WordPress plugin to embed codes.

Download The WPSaviour App Now

Related posts
Best WordPress PluginsBlog

WordPress 5.4 Will Add Lazy-Loading to All Images

Beginner’s GuideBlog

How to Add a Preloader Animation to WordPress (Step by Step)

BlogTutorials

Install WordPress On Ubuntu Locally With LAMP

BlogTutorials

Theme Customizer Boilerplate – Conditional Options, Child Themes and Plugins

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.