.wp-block-code code {
  white-space: pre-wrap !important;
  word-break: break-all !important;
}
@media (prefers-color-scheme: dark)
@media print {
    /* FORCE THE PAGE AND BODY TO BE STANDARD BLOCKS (Kills Flexbox/Grid) */
    html, body, #page, .site, #content, .site-content, main, #main, .content-area {
        display: block !important;
        float: none !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
    }

    /* Hide the sidebars and extraneous elements */
    .sidebar, #sidebar, .widget-area, 
    header, footer, .site-header, .site-footer, 
    .comments-area, #comments {
        display: none !important;
    }

    /* FORCE PAGE BREAKS AT THE START OF EACH POST */
    article, .post, .hentry, .wp-block-post {
        display: block !important;
        clear: both !important;
        page-break-before: always !important; /* For older browsers */
        break-before: page !important;        /* Modern standard */
    }
}
Use code with caution.

💡 A "Zero-Code" Alternative (If CSS Still Fails)

If your WordPress theme uses deeply nested, stubborn layouts that refuse to break, you can skip CSS entirely and use a dedicated WordPress printing plugin.
A highly rated option is Print My Blog. It is specifically designed to take your entire blog, strip out sidebars/headers automatically, and cleanly inject physical page breaks between every single post before rendering it into a clean print layout or PDF.
Did resetting the containers to display: block solve the problem in your print preview? If you still see multiple posts clustered on one page, letting me know your theme's name will help me pinpoint the exact container block causing the layout lock.
• 
Stack Overflow
Page-break-inside:avoid not working - Stack Overflow
December 30, 2015 — For consistent behavior with `page-break-inside: avoid;` it is advisable to avoid using CSS properties such as `float`, `flex`, `g...
• 
GitHub
Page Breaks for Print Preview Broken by display: flex - GitHub
Adding the following CSS code after all the style information in an exported HTML version of the notebook fixes the issue
• 
YouTube·Michael Nelson
How to Control Page Breaks and Image Placement in Print ...
Oct 4, 2021 — Print My Blog ensures images are not cut in half by moving them to the next page by default, which can result in white space. enab...
40s
