I am trying to set that when there is no featured image, it should look for the first image in the article and post that. I tried a few approaches, but none seemed to work.
Am I able to use post_thumbnail_html with this theme?
For example, I tried this in functions.php
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) {
$img = 'ID) . '" />';
apply_filters('post_thumbnail_html', $img, $post->ID, $attachment_id);
}
}
}
}
add_action('the_post', 'auto_featured_image');
Hi,
The featured image has to be entered manually in the required field in the post edit screen, and the theme will create the necessary thumbs from this image and display them on the modules/blocks. This is how the theme works and the post structure is designed. The featured image is specifically called in every post structure that can display it. Maybe you can do it through a plugin that has this kind of capabilities. Or you can try to search for this here on the forum, maybe some other users have managed to implement something like you want.
Thanks
I know you have the option of entering a manual fallback – but that won’t work for me.
I am switching my site from a previous theme which didn’t use featured images – but I don’t want all of my existing articles to show the default image.
What I am trying to do is pull the first photo when there is no featured image, but it seems your theme is ignoring post_thumbnail_html from functions.php
If I would want to change it within the theme, which file would I go to find the featured image coding?
Thanks!
Hi,
The easiest way to achieve this would be by using a plugin with that kind of capability. A similar topic is this one – https://forum.tagdiv.com/topic/getty-images-plugin/
You could try that plugin or a similar one and see if you can manage to use it for your website in that situation.
It would be very difficult to override the theme function, and the automatic process from uploading a featured image from media library, then use it on the post templates. Not to mention all the modules that depend on the thumbs that can only be created from the featured image. Please try using a plugin for this, and let us know how it goes.
Thanks