-
lumostoria
Hi,
A couple of weeks ago, I installed GeneratePress Premium in my WordPress instance (7.0) and created a blogging website based on your starter site ‘Craft’. Everything works as expected except the predefined 404 page. When the 404 page is displayed on a desktop PC with maximized browser window, it looks like this:

The 404 block is only displayed in 1/3 of the width of its parent container. However, if I reduce the width of the browser window to about the half, the 404 block pops to the full width of its parent container, it now looks like this:

In my opinion, the 404 block “thinks” it has to be displayed in a column of a 3-column grid and only if the width of the browser window is reduced it jumps to full size. When looking at the HTML code, there is a CSS class ‘grid-sizer’ that seems to be responsible for this erroneous behavior:

In the GeneratePress elements, I cannot find the place where the 404 page inherits this 3-column grid pattern. In my opinion, the current behavior is not correct since the 404 block should always be displayed in full width.
Would you mind to check whether this error can be corrected in GeneratePress?
Thanks for your help.
Cheers, Sven
-
Alvind
Hi Sven,
I’m not sure how that happened, but we can take a closer look at the settings if you’re able to provide a temporary admin login.
Alternatively, you can try this CSS, which should fix the layout:
.error404 #post-3496.generate-columns { width: 100%; } -
lumostoria
I would appreciate if you could have a look at the settings. The admin logon info is in the private area.
-
George
Hi Sven,
The cause is your permalink structure (
/blog/%postname%/). Because your post URLs sit under a/blog/base, a non-existent URL in that path gets parsed as the blog/posts context before WordPress falls through to the 404. The result is that the main query is populated with real posts on the 404 page, so your blog column/masonry settings apply to it — which is why the 404 content ends up inside agrid-33column with thegrid-sizerelement, and why it only “fixes” itself when you narrow the window and hit the mobile breakpoint.It’s not the 404 template inheriting a grid; it’s the populated query running through your blog columns layout.
You can disable columns specifically on the 404 by adding this to a code snippet (or your child theme’s
functions.php):add_filter( 'option_generate_blog_settings', function ( $options ) { if ( is_404() ) { $options['column_layout'] = false; $options['masonry'] = false; $options['featured_column'] = false; } return $options; } );That forces the 404 to render full width regardless of your blog column settings.
-
lumostoria
Hi George,
Thanks for taking the time to analyze the problem and explain the behavior. However, I still have a question regarding your explanation. You wrote:“The cause is your permalink structure (/blog/%postname%/). Because your post URLs sit under a /blog/ base, a non-existent URL in that path gets parsed as the blog/posts context before WordPress falls through to the 404. The result is that the main query is populated with real posts on the 404 page, so your blog column/masonry settings apply to it — which is why the 404 content ends up inside a grid-33 column…”
So you say that the “erroneous” 404 behavior occurs for non-existing URLs within the /blog/ path, right?
However, exactly for these URLs the 404 behaviour is correct. When I call
<my-website>/blog/test123
the 404 page is displayed correctly and the HTML does not contain the grid-sizer element. Only if I call
<my-website>/test123
the 404 page is displayed incorrectly using the grid-sizer element. From your explanation, I would have expected exactly the opposite behavior.
Best regards,
Sven -
George
Hi Sven,
I traced this to the exact cause in GeneratePress’s blog module.
When you request a non-existent URL at the site root (
/test123), WordPress correctly flags it as a 404 and displays your 404 template — but it also runs the main posts query first, and that query comes back holding posts. Those posts are never displayed (the 404 template doesn’t loop over them, which is why you don’t see any posts on the page), but they’re still sitting in the query.GeneratePress decides whether to wrap the content in its column/masonry layout by checking the current post type. Because the query is holding posts, that check passes — so the column wrapper (the
grid-sizerelement andgrid-33width) gets added around your 404 content, even though no posts are shown.A non-existent URL under your blog base (
/blog/test123) returns an empty query, so that check finds nothing, and the 404 renders correctly at full width. That’s the entire difference between the two.Disabling columns specifically on 404s is the right fix. The snippet you applied handles it. As a more targeted alternative, this filter does the same thing:
add_filter( 'generate_blog_columns', function ( $columns ) { return is_404() ? false : $columns; } ); -
lumostoria
Hallo George,
Thanks again for the explanation and your patience. I installed the blank GeneratePress child theme and added the code snippet to its functions.php. Works fine, 404 page is now always displayed “fullscreen”.
Cheers,
Sven -
George
Ok, Sven, no problem!
- You must be logged in to reply to this topic.