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 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to create a dynamic infinite logo slider with ACF and Bricks

How to create a dynamic infinite logo slider with ACF and Bricks

This tutorial provides the builder settings, PHP & CSS codes that can be pasted in order to create an infinite logo slider in pure CSS…
Pro
Accordion Grid Query Loop in Bricks

Accordion Grid Query Loop in Bricks

How to set up a accordion in Bricks such that the "titles" are arranged in a grid with the full width content opening below.
Categories:
Pro
Dynamic Posts Lightbox in Bricks using GLightbox

Dynamic Posts Lightbox in Bricks using GLightbox

Steps to set create a dynamic lightbox with content from the post inside of the query loop.
Categories:
Pro
Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Parent Query Loop Object – Traversing Nested Query Loops Up in Bricks

Bricks enables us to build nested query levels of unlimited levels. Here are a couple of examples: Sometimes, you might want to obtain the parent…
Categories:
Pro
Events grouped by Event Date custom field in Bricks

Events grouped by Event Date custom field in Bricks

This Pro tutorial for Bricks users provides the steps to output posts of an event custom post type dynamically grouped by the value of their…
Categories:
Pro
Recently Viewed Posts Bricks Query Loop

Recently Viewed Posts Bricks Query Loop

How to output the most recent X number of posts (any post type) viewed by the current visitor.
Categories:
Pro
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags: