1. Home
  2. Knowledge Base
  3. Tasty Recipes
  4. Customizing Tasty Recipes
  5. Filter: Prevent Tasty Recipes from converting nutrition information

Filter: Prevent Tasty Recipes from converting nutrition information

Tasty Recipes automatically converts nutrition information that is stored in your database. However, if you do not want this information to be converted, you can place the following code in your 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( 'tasty_recipes_convert_recipe', function( $converted_data ) {
	$nutrition_fields = array(
		'calories',
		'fat',
		'carbohydrates',
		'protein',
		'trans_fat',
		'saturated_fat',
		'unsaturated_fat',
		'sodium',
		'sugar',
		'cholesterol',
		'fiber',
		'serving_size',
	);
	foreach( $converted_data as $key => $value ) {
		if ( in_array( $key, $nutrition_fields ) ) {
			unset( $converted_data[ $key ] );
		}
	}
	return $converted_data;
});
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support