Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbachhuber/dab1348dc33a7c8b6c81af6097313828 to your computer and use it in GitHub Desktop.
Save danielbachhuber/dab1348dc33a7c8b6c81af6097313828 to your computer and use it in GitHub Desktop.
Use the post's featured image when the EasyRecipe doesn't have an image.
<?php
/**
* Use the post's featured image when the EasyRecipe doesn't have an image.
*
* @param integer $image_id Image ID to be used.
* @param object $recipe Tasty Recipe object.
* @param integer $post_id Original post ID.
*/
add_filter( 'tasty_recipes_convert_easyrecipe_image_id', function( $image_id, $recipe, $post_id ) {
if ( $image_id ) {
return $image_id;
}
return get_post_thumbnail_id( $post_id );
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment