Archived topic
Generateblocks background is not displayed when category returns nothing.
5 replies · Started by Luiz Guilherme on July 28, 2021
Using "page hero" + "Generateblocks", I created a template with a custom fallback image (I disable the post image) and applied it to the entire site.
Worked perfectly.
However, on category pages that do not return any results, the image is not displayed.
If I also set a solid color for the background, that color is displayed, but the image never is.
Immediately after I assign some post to category, the background image starts to be displayed.
Is this a bug?
Hi Luiz,
This isn't a bug but a default behavior.
Category archives don't have featured image by default so it just fetches the featured image of the first post it gets.
You can add a fallback image to the container block's Background tab so there's still a default fallback image for the empty categories.
But if you want a featured image for each category, you'll need a plugin that allows you to do for them as WordPress default doesn't have this feature.
Hi. Elvin.
As I explained, this is exactly what I did.
"Set a fallback image"
And it doesn't show up on the pages I've quoted.
Take a test:
01
* Define a fallback image.
* Create a category, and do not assign any posts to this category.
* Access this category "No posts".
* You will see that the image will not be displayed.
* By assigning any post to this category the fallback image will be displayed.
Hi there,
the function currently relies on checking the current-post for its ID. Without the ID the rest of the conditional checks would fail so the function simply returns nothing. So it doesn't ( and wasn't intended to ) work for templates that don't support Featured Images or Custom Fields. e.g Category Archives.
Its an odd one to fix as when would you want to display an empty Archive ?
But i can have a chat with Tom regarding this - as it might be something we can easily change.
Hey David.
Thanks for the feedback.
In fact, no one wants to display an empty archive page, or an empty search result.
However, this can happen, and this would affect the user experience, seeing a broken and incomplete page.
I always like to cover all gaps to give the user the best experience possible.
We're looking at what is possible there.
Currently the best way to make sure its not missing an image is to use Element specifically for archives that uses a static image. We'll see what we can do :)