unable to make changes

edited November 2019 in Theme support
Hello,

When I try to add this code to functionphp it doesn't make any changes. is there a specific .php file for posts/thumbnails.

/*function: generate featured image automatically*/
function autogen_featured_img() {
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);
}
}
}
}

Comments

Sign In or Register to comment.