Many recipe plugins use specific fonts that are not the same font that is used everywhere else on your website. These fonts often recognize and display special characters, such as ⅛ or ¼ instead of 1/8 or 1/4. 

Because Tasty Recipes doesn't set a specific font to be used for display, it relies on your website's fonts. If your website's font doesn't recognize these special characters, it will display a "?" in place of the special character. 

To eliminate this problem, we have created a filter for Tasty Recipes that recognizes these special characters and turns them into their plain-text variety. Place the code below in your active theme's functions.php file.

***Before doing this, make sure that you have access to your site's files via FTP (the editor in WordPress is not sufficient in case problems arise) and that you are comfortable with editing your functions.php file. Any minor error in the functions.php file can result in the "white screen of death," which is easily fixed via FTP but is difficult to fix otherwise (and a nuisance as your site will be unavailable until fixed).***

add_filter( 'do_shortcode_tag', function( $output, $tag ){
if ( 'tasty-recipe' !== $tag ) {
return $output;
}
$reverse_fractions = array(
'½'     => '1/2',
'⅓'      => '1/3',
'¼'     => '1/4',
'⅕'      => '1/5',
'⅙'      => '1/6',
'⅛'      => '1/8',
'⅔'      => '2/3',
'¾'     => '3/4',
'⅜'      => '3/8',
'⅘'      => '4/5',
'⅚'      => '5/6',
'⅝'      => '5/8',
'⅞'      => '7/8',
);
foreach( $reverse_fractions as $key => $value ) {
$reverse_fractions[ html_entity_decode( $key ) ] = $value;
}
return str_replace( array_keys( $reverse_fractions ), array_values( $reverse_fractions ), $output );
}, 10, 2 );

Note: This filter will only work on WordPress 4.7+. If you are running an older version of WordPress, please update to 4.7+ before using this filter.

Did this answer your question?