Last active
October 11, 2019 08:01
-
-
Save christiaansnoei/034f9d130a72059969be764a7d654308 to your computer and use it in GitHub Desktop.
Get the featured image in WordPress when set, if not a fallback will be loaded.
This file contains hidden or 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 | |
| if( has_post_thumbnail() ): | |
| $featured_thumb_id = get_post_thumbnail_id(); | |
| $featured_thumb_url_array = wp_get_attachment_image_src( $featured_thumb_id, 'large', true ); | |
| $featured_image = $featured_thumb_url_array[0]; | |
| else: | |
| $featured_image = get_template_directory_uri() . '/assets/images/default.jpg'; | |
| endif; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment