Where to include conditional logic in WordPress block style templates?

I am trying to rewrite a classic WP theme as a block theme. In my current classic theme, where I display a list of posts, I use php logic to display or hide certain elements. E.g.: If a post includes a video, I overlay a video icon over the featured image in the list. In the picture below, the post on the left includes a video, so it gets an icon. I had started building a pattern to be used in a query loop block, but since patterns don't have access to post data, I cannot use any conditional post-based logic. From Wordpress.org Theme Handbook: At a practical level, this means that a lot of data is unavailable during the registration process on init. Your patterns cannot access things like the global query or post. They also cannot use functions associated with that data. So this means that WordPress functions like is_home(), is_single(), get_post(), and others are simply not ready yet. Where is the appropriate place to include this sort of logic check in a block based theme?

Comment (0)

You’ll be in good company