Dynamic Horizontal Posts Accordion in Bricks

Update on 8 Sep 2024: You may want to follow the newer version that considers accessibility.


Looking to make a Horizontal Image Accordion dynamic?

This article for Pro members provides JSON code that can be pasted in your Bricks Page/template to show the featured images, titles and excerpts of the 5 latest posts.

We shall also update a few query parameters to make it more performant.

Step 1

Copy the following JSON and paste in your Page/template when it is being edited with Bricks.

JSON Link

Step 2

Add the following in child theme‘s functions.php or a code snippets plugin:

add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
    if ( $element_id === 'pvpbud' ) {
        $query_vars['no_found_rows'] = true;
        $query_vars['update_post_meta_cache'] = false;
        $query_vars['update_post_term_cache'] = false;
    }

    return $query_vars;
}, 10, 3 );

Replace pvpbud with the Bricks ID of the element on which query loop is enabled.