{"id":26,"date":"2025-11-11T02:32:51","date_gmt":"2025-11-11T02:32:51","guid":{"rendered":"https:\/\/studiorder.com\/?p=26"},"modified":"2026-04-07T23:47:22","modified_gmt":"2026-04-07T23:47:22","slug":"beyond-the-overlay-how-to-move-wordpress-gallery-captions-below-the-image","status":"publish","type":"post","link":"https:\/\/studiorder.com\/?p=26","title":{"rendered":"Beyond the Overlay: How to Move WordPress Gallery Captions Below the Image"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">The core WordPress Gallery block is powerful, fast, and convenient. <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It\u2019s a fantastic tool for creating beautiful, responsive image grids in seconds. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But it has one default styling choice that drives many designers and artists crazy: the captions appear as an overlay on top of the images.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a clean, minimalist portfolio, you often want the art to speak for itself. The ideal layout is a simple, elegant caption positioned neatly&nbsp;<em>below<\/em>&nbsp;the image, not obscuring it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you\u2019ve ever tried to fix this, you may have fallen down a rabbit hole of CSS fixes that cause new, frustrating bugs\u2014like images in your gallery suddenly stretching or squashing!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Don&#8217;t worry. In this guide, we&#8217;ll walk through the definitive, professional way to solve this. We will create a clean, reusable&nbsp;<strong>Block Style<\/strong>&nbsp;that gives you a &#8220;one-click&#8221; option to apply your beautiful new caption style to any gallery on your site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Goal: From Overlay to Understated<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s what we\u2019re trying to achieve.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Before:<\/strong>&nbsp;The default WordPress style, with captions overlaying the bottom of the image.<br><strong>After:<\/strong>&nbsp;Our new &#8220;Elegant Captions&#8221; style, with clean, left-aligned text directly underneath each piece of artwork.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Solution: Creating a Custom &#8220;Elegant Captions&#8221; Block Style<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll accomplish this in two main steps. First, we&#8217;ll tell WordPress about our new style using a bit of PHP. Second, we&#8217;ll provide the CSS to make it look perfect.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Register the New Block Style in&nbsp;functions.php<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is the magic step that creates a new style button in the block editor&#8217;s sidebar.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to your theme&#8217;s\u00a0functions.php\u00a0file. The best practice is to use a\u00a0<strong>child theme<\/strong>\u00a0to ensure your changes aren&#8217;t lost when the parent theme updates. You can find this file under\u00a0<strong>Appearance \u2192 Theme File Editor<\/strong>.<\/li>\n\n\n\n<li>Scroll to the bottom of the file and paste the following PHP code:<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">codePHP<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function my_theme_register_gallery_style() {\n    register_block_style(\n        'core\/gallery', \/\/ We are targeting the core Gallery block\n        &#91;\n            'name'  =&gt; 'elegant-captions', \/\/ This becomes the CSS class for styling\n            'label' =&gt; 'Elegant Captions', \/\/ This is the name you'll see in the editor\n        ]\n    );\n}\nadd_action( 'init', 'my_theme_register_gallery_style' );<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click\u00a0<strong>&#8220;Update File&#8221;<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it! WordPress now knows about your new style. Now, we just need to tell it what that style should look like.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Add the Custom CSS<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is the code that performs the magic. It moves the caption, fixes the layout bugs this change can cause, and ensures perfect alignment.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate to\u00a0<strong>Appearance \u2192 Customize \u2192 Additional CSS<\/strong>. This is the easiest place to add sitewide CSS.<\/li>\n\n\n\n<li>Paste the following complete CSS block into the editor:<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">codeCSS<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\n * ===================================================================\n *  CSS for the \"Elegant Captions\" Block Style\n *  This code will ONLY activate when the style is selected.\n * ===================================================================\n *\/\n\n\/*\n * PART 1: The Core Caption Styling\n * This takes your original, working code and applies it to the new style.\n*\/\n.is-style-elegant-captions.wp-block-gallery.has-nested-images figure.wp-block-image figcaption {\n    position: relative !important;\n    color: #000;\n    background: none;\n    line-height: 1.4;\n    margin-top: 0.5em;\n    text-shadow: none;\n    text-align: left;\n    padding: 0;\n    overflow: visible;\n}\n\n\/* Removes the default theme overlay\/gradient *\/\n.is-style-elegant-captions.wp-block-gallery.has-nested-images figure.wp-block-image:has(figcaption):before {\n    display: none !important;\n}\n\n\n\/*\n * PART 2: The Surgical Fixes for Layout Bugs\n * These rules ONLY activate when \"Crop images\" is toggled on,\n * preventing the common \"squashed images\" bug.\n*\/\n\n\/* This fixes the caption alignment when crop is on *\/\n.is-style-elegant-captions.wp-block-gallery.is-cropped .wp-block-image {\n    padding: 0 !important;\n}\n\n\/* This is the magic fix for the image proportion bug! *\/\n.is-style-elegant-captions.wp-block-gallery.is-cropped {\n    align-items: flex-start !important;\n}<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click\u00a0<strong>Publish<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Why This CSS Works<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>.is-style-elegant-captions: This prefix ensures our code\u00a0<strong>only<\/strong>\u00a0runs on galleries where you&#8217;ve selected our new style.<\/li>\n\n\n\n<li>position: relative !important;: This is the core of the change, moving the caption back into the normal document flow.<\/li>\n\n\n\n<li>align-items: flex-start !important;: This is the crucial fix. When you move the caption, the gallery&#8217;s flexbox layout can break, causing images in rows after the first to stretch or squash. This command tells the gallery: &#8220;Let every image be its own natural height.&#8221; It single-handedly solves the most frustrating layout bug.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Apply Your New Style!<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now for the rewarding part.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Edit any page with a Gallery block.<\/li>\n\n\n\n<li>Click on the gallery to select it.<\/li>\n\n\n\n<li>In the sidebar on the right, make sure you are on the &#8220;Styles&#8221; tab (the half-filled circle icon).<\/li>\n\n\n\n<li>You will see the &#8220;Default&#8221; style and your new\u00a0<strong>&#8220;Elegant Captions&#8221;<\/strong>\u00a0style. Click it.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Instantly, you&#8217;ll see your captions snap into place below the images, right in the editor. Save the page, and you&#8217;ll see the same beautiful, clean result on your live website.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ve now taken control of the core gallery block and created a clean, professional, and completely reusable style for any artist portfolio or image grid on your site. Happy creating<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The core WordPress Gallery block is powerful, fast, and convenient. It\u2019s a fantastic tool for creating beautiful, responsive image grids in seconds. But it has one default styling choice that drives many designers and artists crazy: the captions appear as an overlay on top of the images. For a clean, minimalist portfolio, you often want [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studiorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":1,"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":27,"href":"https:\/\/studiorder.com\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions\/27"}],"wp:attachment":[{"href":"https:\/\/studiorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studiorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studiorder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}