How to Overlay Post Titles and Excerpts on Featured Images in a Query Loop Grid
Content
Many WordPress users want to create a visually appealing posts grid where the title and excerpt elegantly overlay the featured image. This is a common design pattern, but implementing it with the Query Loop block can be tricky if you're not familiar with CSS. This guide will walk you through the most common solutions.
Why This Problem Occurs
The core WordPress editor and most block themes do not include a built-in setting to create this specific overlay effect. The Query Loop block outputs a standard structure of HTML elements, and without additional styling, the post title, excerpt, and featured image simply stack vertically or horizontally. To achieve the overlapping design, you need to use CSS to control the positioning of these elements.
Common Solutions
1. Using Custom CSS (The Most Common Method)
The primary way to achieve this overlay is by adding Custom CSS to your site. This involves using CSS properties like position: absolute to layer the text elements on top of the image. Based on community discussions, here is a sample CSS code that can serve as a starting point. You will need to add this to your theme's Additional CSS section (Appearance > Customize > Additional CSS) or via a child theme.
.wp-block-post {
position: relative;
}
.wp-block-post-featured-image {
margin-bottom: 0;
}
.wp-block-post-content {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 1em;
color: white;
background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
}
Important Note: The exact CSS selectors (like .wp-block-post-content) can vary significantly depending on your active theme. You will likely need to use your browser's inspector tool to identify the correct classes generated by your specific theme and adjust the code accordingly.
2. Exploring Block Plugins
If writing CSS code is not feasible for you, another option is to look for a well-made block plugin that includes a posts grid block with built-in overlay options. While the 'Requests and Feedback' forum does not endorse specific products, searching the WordPress Plugin Directory for terms like "posts grid" or "query loop" may help you find a suitable solution that adds this UI functionality directly into the block editor.
3. Checking Your Theme's Built-in Options
Some more advanced themes include their own custom blocks or settings for designing post grids. Before attempting other methods, thoroughly check your theme's documentation and the settings panel of its specific query loop or posts grid blocks. You may find an overlay option already available.
Conclusion
Creating an text overlay on featured images in a Query Loop is a classic case of needing to bridge a design gap with custom code. The most reliable and lightweight method is to use Custom CSS. Always remember to test any code changes on a staging site first and use a child theme to prevent your modifications from being overwritten by theme updates.
Related Support Threads Support
-
Overlay featured image with post title and excerpthttps://wordpress.org/support/topic/overlay-featured-image-with-post-title-and-excerpt/
-
create Custom HTML block via APIhttps://wordpress.org/support/topic/create-custom-html-block-via-api/
-
Newbie trying to learn custom post templateshttps://wordpress.org/support/topic/newbie-trying-to-learn-custom-post-templates/
-
Header overlaps my blog postshttps://wordpress.org/support/topic/header-overlaps-my-blog-posts/
-
Please add automatic carousel without using a pluginhttps://wordpress.org/support/topic/please-add-automatic-carousel-without-using-a-plugin/
-
Different logo on different pageshttps://wordpress.org/support/topic/different-logo-on-different-pages-2/
-
How can I use the same Forum Design As WordPress.orghttps://wordpress.org/support/topic/how-can-i-use-the-same-forum-design-as-wordpress-org/
-
QUERY LOOP Custom CSS: Overlay feature image on Posts Gridhttps://wordpress.org/support/topic/query-loop-custom-css-overlay-feature-image-on-posts-grid/
-
How to customize post pagehttps://wordpress.org/support/topic/how-to-customize-post-page/
-
Need Pattern Overrides for Query Loophttps://wordpress.org/support/topic/need-pattern-overrides-for-query-loop/
-
Missing Thumbnail on WordPress Site for Embedded FB Videohttps://wordpress.org/support/topic/missing-thumbnail-on-wordpress-site-for-embedded-fb-video/
-
How to use strip_tags() for Query Loop Block in functions.phphttps://wordpress.org/support/topic/how-to-use-strip_tags-for-query-loop-block-in-functions-php/
-
Post link block as container (feature request)https://wordpress.org/support/topic/post-link-block-as-container-feature-request/
-
Blog posts title cut off by headerhttps://wordpress.org/support/topic/blog-posts-title-cut-off-by-header/
-
Adding internal links to my posts as cards without iframeshttps://wordpress.org/support/topic/adding-internal-links-to-my-posts-as-cards-without-iframes/
-
Multiple post types in one query loop?https://wordpress.org/support/topic/multiple-post-types-in-one-query-loop/
-
[NSFW] self hosted video block does not seem to have thumbnail facilityhttps://wordpress.org/support/topic/self-hosted-video-block-does-not-seem-to-have-thumbnail-facility/
-
Post Comments design coming from Theme – no customization allowedhttps://wordpress.org/support/topic/post-comments-design-coming-from-theme-no-customization-allowed/