• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar

Dr Andy Teh

Healthcare Quality Consultant

  • Home
  • Archive
  • About
  • Contact
You are here: Home / WordPress / How to Fix the Ampersand Issue When Using SyntaxHighlighter Evolved WordPress Plugin
post

How to Fix the Ampersand Issue When Using SyntaxHighlighter Evolved WordPress Plugin

When using SyntaxHighlighter Evolved WordPress plugin out of the box, the display output of the ampersand (&) is &. Adding a few lines of code in the functions.php file of my site's child theme fixed the issue.

November 18, 2020 Leave a Comment

I installed the SyntaxHighlighter Evolved plugin yesterday to display WordPress and Stata code fragments.

Unfortunately, the ampersand (&) was displayed as &. A simple Google search informed me that this was a known issue.

The solution I found involved adding the following code (derived from this support thread) in the functions.php file of the active skin of Dynamik Website Builder, running on the Genesis Framework.

//* Fix display of ampersands when using SyntaxHighlighter Evolved plugin
function kagg_syntaxhighlighter_precode( $code, $atts, $tag ) {
   if ( 'code' === $tag ) {
      $code = wp_specialchars_decode( $code, ENT_QUOTES );
   }
   return $code;
}
add_filter( 'syntaxhighlighter_precode', 'kagg_syntaxhighlighter_precode', 10, 3 );

Filed under: WordPress  Tagged with: ampersand, SyntaxHighlighter Evolved

Reader Interactions

Leave a Reply Cancel reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Copyright © 2021 Dr Andy Teh