Answers for "show featured image in posts list wordpres"

PHP
1

wordpress featured image show

<?php echo the_post_thumbnail(); ?>
Posted by: Guest on July-09-2020
0

wordpress posts grab first image for featured image

function auto_featured_image() {
    global $post;
 
    if (!has_post_thumbnail($post->ID)) {
        $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
         
      if ($attached_image) {
              foreach ($attached_image as $attachment_id => $attachment) {
                   set_post_thumbnail($post->ID, $attachment_id);
              }
         }
    }
}
// Use it temporary to generate all featured images
add_action('the_post', 'auto_featured_image');
// Used for new
Posted by: Guest on March-28-2021

Code answers related to "show featured image in posts list wordpres"

Browse Popular Code Answers by Language