16th May '26
/
0 comments

How to move data attributes from outer element to nested element in Bricks

Consider a scenario where a Container/Block in Bricks is made up of image on the left side and a heading with text blurb on the right with both image and heading linking to the same URL.

It is recommended to follow a Single Action Pattern in this case by setting aria-hidden: true and tabindex: -1 for the heading element's anchor tag for accessibility.

The problem though is that when these custom data attributes are added to the heading element, they apply to the heading itself:

when they should be applied to h4 > a, like this:

This Pro tutorial provides the code snippet for this.

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

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to Remove Name and Website Fields in Bricks Comment Forms

How to Remove Name and Website Fields in Bricks Comment Forms

Updated on 14 Mar 2024 In the BricksLabs Facebook group a user asked: What is the best method to remove fields from the Bricks "Comments"…
Filtering out Media Items from “Select post/page” Bricks control

Filtering out Media Items from “Select post/page” Bricks control

The dropdown that appears after choosing "Internal post/page" when setting a link in Bricks shows media (attachment) items besides Pages, Posts and other CPTs. If…
How to Exclude Elements from Bricks Editor

How to Exclude Elements from Bricks Editor

Bricks has a handy bricks/builder/elements filter using which the available elements that show up after clicking + (or ⌃/⌘ + ⇧ + E) in the…
Categories:
Tags:
How to create filters with IsotopeJS in Bricks (Part 1)

How to create filters with IsotopeJS in Bricks (Part 1)

This tutorial series will explore the IsotopeJS library's features inside the Bricks ecosystem.
Categories: