Skip to content

Instantly share code, notes, and snippets.

@leonardop21
Last active June 15, 2021 11:59
Show Gist options
  • Select an option

  • Save leonardop21/2294d031523fa2433f23ce47e40da8f4 to your computer and use it in GitHub Desktop.

Select an option

Save leonardop21/2294d031523fa2433f23ce47e40da8f4 to your computer and use it in GitHub Desktop.
Exibir imagens destacadas no Wordpress
<?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