Hi Strothi,
Yes that’s possible with a little extra code.
There are several examples in the FAQ: https://wordpress.org/plugins/default-featured-image/#faq
Let me know if you need any help with the code.
Jan-Willem
Dear @janwoostendorp,
Thanks, I checked the FAQ and got it to work for the post types as outlined in the FAQ, but not for the archive page. For posts, pages and categories it’s all clear, but how can I target archives?
Kind regards, Philip
Dear @janwoostendorp,
Thanks for the links. I’m not really a programmer myself, but I tried anyhow. Seeing that is_archive() does not accept any parameters, I tried multiple variations of getting is_post_type_archive() to work, but haven’t been successful so far. I modeled my code after the code that works for the CPT:
function dfi_posttype_archive ( $dfi_id, $post_id ) {
$post = get_post($post_id);
if (is_post_type_archive( $post_types = 'papers') ) {
return 19583; // the image id
}
return $dfi_id; // the original featured image id
}
add_filter( 'dfi_thumbnail_id', 'dfi_posttype_archive', 10, 2 );
But it doesn’t work and neither have my other tries, hence I would really appreciate a lot if you could help me out here!
Thanks a lot in advance.
Kind regards, Philip
Hello Strothi,
That’s not a problem. This will set 19583 as the DFI on the archive url of papers.
function dfi_posttype_archive ( $dfi_id, $post_id ) {
if (is_post_type_archive( 'papers') ) {
return 19583; // the image id
}
return $dfi_id; // the original featured image id
}
add_filter( 'dfi_thumbnail_id', 'dfi_posttype_archive', 10, 2 );
Let me know how it goes and if you need any help.
Dear @janwoostendorp,
Unfortunately, it doesn’t – I had tried that also before, but it’s unfortunately not working. I noticed though that I also don’t get any feature image that I set with your plugin for e.g. my blog post page or any other archive?!
It works fine for posts / cpts without a featured image as well as for pages, but I don’t get it to work on archive pages, neither for specific archives, nor for any archives in general?!
Kind regards, Philip