1. Home
  2. Knowledge Base
  3. Tasty Links
  4. Filter: Limit links to only recipe ingredients

Filter: Limit links to only recipe ingredients

If you'd rather Tasty Links only show up inside the ingredients section of your Tasty Recipes, simply add the below PHP snippet to your theme's functions.php file:

 * Disable Tasty Links except for on Tasty Recipes ingredients.
add_action( 'init', function() {
	// Remove Tasty Links from the main post content.
	remove_filter( 'the_content', array( 'Tasty_LinksFrontend', 'filter_the_content' ), 8 );
	// Remove Tasty Links from Tasty Recipes description, notes, ingredients, and instructions.
	remove_filter( 'tasty_recipes_the_content', array( 'Tasty_LinksIntegrationsTasty_Recipes', 'filter_tasty_recipes_content' ) );
	// Remove Tasty Links from editor previews
	remove_filter( 'the_editor_content', array( 'Tasty_LinksAdmin', 'filter_the_editor_content' ) );
	// Add Tasty Links back, but only on ingredients.
	add_filter( 'tasty_recipes_recipe_template_vars', function( $template_vars ){
		if ( class_exists( 'Tasty_LinksIntegrationsTasty_Recipes' ) ) {
			$template_vars['recipe_ingredients'] = Tasty_LinksIntegrationsTasty_Recipes::filter_tasty_recipes_content( $template_vars['recipe_ingredients'] );
		return $template_vars;

Links should stop appearing anywhere in the post content outside the Tasty Recipes ingredients area.

Was this article helpful?

Related Articles

Need Support?

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