When building a website for a construction company or similar client, a well-structured gallery template can be invaluable for showcasing individual projects or homes. Here’s a step-by-step guide to setting up a dynamic gallery template using Advanced Custom Fields (ACF), GeneratePress as the theme, and GenerateBlocks, ensuring that each gallery post maintains a cohesive, professional design.
Step 1: Add a Custom Post Type for Galleries
To begin, create a new custom post type for the galleries. This allows each project or home to have its own dedicated page.
- In ACF, navigate to Post Types and select Add New.
- Set up the post type:
- Plural Name: Galleries
- Singular Name: Gallery
- For a clean, professional look, customize the icon for this post type:
- Go to Advanced Configuration for your new post type.
- Change the icon to something relevant, like a gallery or photo icon.
After saving your changes, you’ll see “Galleries” in the WordPress sidebar. This post type will now be used to create individual galleries.
Step 2: Create a Gallery Page Template with GeneratePress Elements
GeneratePress Elements is a powerful tool for creating reusable templates. Here’s how to set up a gallery template to display a page header and gallery content:
- Go to Appearance > Elements in the WordPress dashboard.
- Select Add New and choose Block as the element type. This will open the block editor.
- Title your new element “Gallery Page Template” and set Element Type to Content Template.
- Set the Editor Width to 100% for an optimal editing experience.
Designing the Template Layout
This layout will include a dynamic header with the gallery title and featured image, followed by a gallery block displaying the images.
Page Hero (Dynamic Header)
- Add a Container Block as the outer wrapper, and nest an Inner Container Block within it.
- Add padding (e.g., 80px top and bottom) to give some space around the title.
- Inside the inner container, add an H1 Headline Block.
- Set the headline text to Dynamic Data and select Current Post Title. This ensures the gallery’s title will automatically display in the header.
- For the background, set it to the Dynamic Featured Image.
- Insert a default background image (this acts as a fallback if no featured image is set).
- Set a gradient overlay for better text readability. Choose a white gradient with opacity, making the text stand out.
- Adjust the Z-index to ensure the title appears in front of the gradient overlay.
Gallery Content Section
- Below the hero section, add another Container Block with an Inner Container.
- Set the inner container width to around 800px for a contained, centered look.
- Inside this container, add a GeneratePress Dynamic Content Block.
- Select Post Content as the source to automatically display the WordPress Gallery Block content you’ll add in each gallery post.
Step 3: Configure Display Rules
Specify where this template will be applied:
- In the Display Rules section, set this template to appear on All Galleries under the custom post type you created.
- Save and publish your template.
Step 4: Create and Populate Gallery Posts
With your template ready, it’s time to create individual gallery posts.
- Go to Galleries > Add New and title your first gallery (e.g., “Modern Home”).
- In the post content, add a Gallery Block and select images relevant to the project.
- Set a Featured Image for each gallery. This will serve as the background image in the page hero.
- Save and publish.
Step 5: Set Up a Query Loop for a Gallery Showcase Page
To create a main gallery showcase page where all projects can be browsed:
- Add a new page (e.g., “Our Work”).
- Insert a GenerateBlocks Query Loop Block. Set it to pull in posts from your Gallery post type.
- Style the query loop to display images, titles, and an overlay for each gallery item. Set up a gradient background for each post and adjust the Z-index to make the title legible over the image.
- Publish this page as the main gallery overview.
Final Adjustments and Testing
- Test the template and gallery posts on desktop, tablet, and mobile to ensure responsiveness.
- For accessibility and readability, adjust padding and text contrast in your headers and overlays as needed.
Summary
With this setup, you’ve created a dynamic and reusable gallery page template that not only maintains a cohesive design across multiple posts but also gives your client an easy way to showcase their projects. By adding a query loop for a main gallery page, you provide users a clear overview, with seamless navigation to each project’s individual gallery.
This template-based approach is flexible, scalable, and works beautifully for any portfolio-focused website.