I’ve just realised something about WordPress block styling, and it’s not good

I have previously grumbled about styling WordPress (WP) blocks in the HTML files that control what is shown in each type of view (post, page, archives, etc.) rather than using semantic classes and CSS. I have realised that by doing this, it will break the Site Editor, which WP place so much emphasis on for creating themes nowadays. I’ve already seen that using the Site Editor has more documentation and support than writing it programmatically.

I am currently looking at adding search.html, which controls how search results are viewed. It’s currently the same as the index and archive pages, except that it has the heading Search results. The page shows a list of hits, if there are any, and a blank page if there aren’t. In the latter case, it would be more helpful to the user to show a message indicating that WP has looked but didn’t find anything, rather than appearing to have not done anything.

I saw that other themes use markup options in their WP query blocks (a query block is needed to get the posts or pages to display), so I had a look on the internet for any documentation about the query block. I found a post about the WP Query Loop, which talked only about creating it in the Site Editor. It talks about settings for this that and the other, which made me think.

If the Site Editor has options, and these options are saved in the HTML that defines the theme, then any semantic classes I use will not be able to be changed in the Site Editor. (I’m not sure if my semantic classes would override the Editor’s settings or vice versa.) When I looked in the Site Editor, my classes appear in Advanced > Additional CSS class(es). The user could, therefore, completely remove my classes. I’m not sure if this is a good thing or a bad thing.

One thing is for sure: I feel yet again thwarted by WP.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.