8th Sep '24
/
2 comments

Dynamic Horizontal Posts Accordion in Bricks

Dynamic Horizontal Posts Accordion in Bricks

Updated on 9 Sep 2024

This Pro tutorial provides the steps to set up a horizontal accordion of featured images of posts output by a Bricks query loop so that each image expands smoothly, making the others shrink as they are hovered.

We shall also have the post titles appear as caption and slide in up from the bottom when hovered with the entire accordion item linking to the corresponding single post's permalink.

Coming to responsiveness, at 992px and below breakpoint we shall reduce the height of the images so they don't appear too vertically stretched. At this breakpoint, the device is likely a tablet and there won't be any hover action, so tapping the images would briefly show the caption (post title) and take the user to the corresponding single post.

At 768px and below, we shall make the accordion items (images) appear one below the other with the post title captions showing up.

Step 1

Register a custom image size for the vertical images in our accordion.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

<?php add_image_size( 'horizontal-accordion-item', 1000, 1563, true ); add_filter( 'image_size_names_choose', function ( $sizes ) { return array_merge( $sizes, [ 'horizontal-accordion-item' => 'Horizontal Accordion Item', ] ); } );

If your posts already have featured images before adding this code, regenerate thumbnails.

Step 2

Edit your Post/Template with Bricks.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

In the Bricks Facebook group a user asks: We can use AI to help unfreeze our brains sometimes or at least have it write the…
Categories:
Pro
Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

Nested Meta Box Query Loop Inside a CPT Query Loop in Bricks

This Pro tutorial provides the steps for setting up a cloneable Meta Box group query inside a CPT query in Bricks. Scenario: CPT: course Meta…
Categories:
Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
Pro
ACPT Gallery Field Query Loop in Bricks

ACPT Gallery Field Query Loop in Bricks

How we can output images from ACPT‘s Gallery field for posts as a grid using a query loop.
Categories:
Pro
Posts Grouped by Years and Months in Bricks

Posts Grouped by Years and Months in Bricks

How display posts organized by months & within years based on the published date.
Categories:
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories:
How to Change Bricks Preloader Background Color

How to Change Bricks Preloader Background Color

Working on a dark-themed site like our friend Storm and getting blinded by the light background of Bricks' preloader screen of the editor? Here's how…
Categories: