1. Home
  2. Knowledge Base
  3. Tasty Recipes
  4. Customizing Tasty Recipes
  5. Filter: Display keywords in recipe cards
  1. Home
  2. Knowledge Base
  3. Tasty Recipes
  4. Filter: Display keywords in recipe cards

Filter: Display keywords in recipe cards

The keywords field in the recipe card is required for the recipe schema. However, it doesn't need to be displayed on the recipe card. For this reason, we hide the keywords by default. If you would like to display the keywords, this custom PHP code snippet can do that.

We recommend using a free code snippets plugin like WP Code to add the following code to your site:

PHP
add_filter( 'tasty_recipes_recipe_template_vars', function ( $template_vars, $recipe ) {
	$recipe_json = $recipe->to_json();
	$template_vars['recipe_keywords'] = $recipe_json['keywords'];
	return $template_vars;
}, 10, 2 );
Was this article helpful?

Related Articles

Need Support?

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