Created
October 22, 2019 20:30
-
-
Save danielbachhuber/04deda4a6296f535e9ff54d9d8172213 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Uses the post's featured image in the recipe card, | |
* if the recipe doesn't have an assigned image. | |
* | |
* @param array $vars Existing template variables. | |
* @return array | |
*/ | |
add_filter( 'tasty_recipes_recipe_template_vars', function( $vars ) { | |
// If there's no image HTML already for the recipe card... | |
if ( empty( $vars['recipe_image'] ) ) { | |
$post_id = get_the_ID(); | |
if ( $post_id ) { | |
$vars['recipe_image'] = get_the_post_thumbnail( $post_id, 'thumbnail' ); | |
} | |
} | |
return $vars; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment