Cover block - accept term/taxonomy featured image
Hello guys 👋
What problem does this address?
When creating a site I stumbled upon an interesting task where I have to display a cover block on an archive page, but the cover block should use the featured image of the term/taxonomy. Unfortunately it looks like the cover block at the moment is only capable of displaying the post featured image.
Is there a way or are there any plans to extend this functionality?
What is your proposed solution?
Maybe make it possible to extend (maybe with a filter) the functionality of the cover image in order to receive the term/taxonomy featured image, not only the post featured image.
At the moment the cover block receives the postId in the context but maybe it should in some situations also accept the termId input and fetch the image accordingly?
@sergiu-radu, are you using a plugin to add featured images for terms/taxonomies?
If I recall correctly, the featured image is only supported for the post types.
Hi @Mamaduka, For simple post types and custom post types I use custom code to add featured image option to terms/taxonomies.
But, for example WooCommerce has the featured image option for categories built in.
Thanks for the clarification, @sergiu-radu!
The core blocks will not be able to handle term/taxonomy featured images until there is native support for this feature in WP core.
The custom implementations can use the render_block_core/group filter and HTML API to change the block's default behavior. You can refer to the current code and adjust the example for your needs.
I'll close this as "can't fix" for now and will be happy to revisit it after native support is available.
Hello @Mamaduka,
I totally understand this and I knew you won't be able to add such a functionality but at least I tried :)
It could be a great feature, the cover block could be used in FSE when creating an archive, we could place it at the top of the loop (like a hero section) and it could take the tax image as a background.
Thank you and have a good day!