Last active
June 15, 2021 11:59
-
-
Save leonardop21/2294d031523fa2433f23ce47e40da8f4 to your computer and use it in GitHub Desktop.
Exibir imagens destacadas no Wordpress
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 | |
| function insert_feature_thumb_feed( $content ) { | |
| global $post; | |
| if(has_post_thumbnail( $post->ID ) ) { | |
| $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full' ); | |
| $content = '<img src="'.$thumbnail[0].'" class="type:primaryImage" width="'.$thumbnail[1].'" height="'.$thumbnail[2].'">'; | |
| } else { | |
| $content = '<img src="https://leonardonascimento.dev/assets/img/no-image.jpg" class="type:primaryImage" width="768" height="512">'; | |
| } | |
| return $content; | |
| } | |
| add_filter( 'the_excerpt_rss', 'insert_feature_thumb_feed' ); | |
| add_filter( 'the_content_feed', 'insert_feature_thumb_feed' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment