If you have a custom recipe card and you're interested in using the new plain-text option for your Nutrifox nutrition information, you can use these code snippets to make all that nutrition magic happen. ✨
Add this to your custom template:
In your tasty-recipes.php file, you will need to add this code snippet, in place of your current Nutifox code:
<?php
// Add the markup below to your custom card.
?>
<?php if ( ! empty( $recipe_nutrition ) ) : ?>
<div class="tasty-recipes-nutrition">
<h3><?php esc_html_e( 'Nutrition', 'tasty-recipes' ); ?></h3>
<ul>
<?php foreach ( $recipe_nutrition as $nutrition ) : ?>
<li><strong class="tasty-recipes-label"><?php echo $nutrition['label']; ?>:</strong> <?php echo $nutrition['value']; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Add this to your functions.php file:
Next you'll add this filter to your theme's functions.php file or similar. The code below changes the Nutrifox display style to card
from its default label
.
/**
* Changes the Nutrifox display style to 'card' from its default 'label'.
*/
add_filter(
'tasty_recipes_nutrifox_display_style',
function() {
return 'card';
}
);
Note: You will need an active Nutrifox subscription.
***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).***