12th May '22
/
0 comments

Custom Posts Grid Layout in Bricks using CSS Grid

Custom Posts Grid Layout in Bricks using CSS Grid

There are at least three ways in which we can build custom loops in Bricks.

  1. Posts element
  2. Turning on Query Loop on a container
  3. Code element

While #2 and #3 give the ultimate flexibility w.r.t the generated HTML output, #1 is pretty handy as well.

This Pro tutorial provides the steps to customize the Posts element's output using CSS Grid to have the 4 latest posts such that the latest is at the top left, the next one spanning two rows, and the next two at the bottom left.

custom-posts-grid-bricks

In the Table Portrait (991px and below), we shall make the posts appear in a 2 x 2 grid and as a single column stacked below each other in Mobile Landscape (767px and below).

Step 1

Add a Posts element inside a container.

Query: 4 Posts Per Page.

Let us show the post's categories and title overlayed on top of the featured image for each post.

There is no built-in dynamic field in Bricks currently to have the categories as separate links that I know of so we can style them to look like this:

So let's define a custom function that returns the linked terms for the specified taxonomy having the specified class (categories in the example below) like this:

<div class="categories"> <a href="https://bricks.local/category/cats/mountains/" rel="tag"> Mountains </a> <a href="https://bricks.local/category/nature/" rel="tag"> Nature </a> </div>

Add the following in your child theme's functions.php or a code snippets plugin like WPCodeBox:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 624 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to Create a Right Overflow Effect on Sliders in Bricks

How to Create a Right Overflow Effect on Sliders in Bricks

In this tutorial, we'll learn how to recreate a nice overflow effect on the right of our sliders in Bricks. Introduction Recently, I've been asked…
Categories:
Pro
How to Insert an Ad or an Element Between Posts in Bricks

How to Insert an Ad or an Element Between Posts in Bricks

How to insert an image or any Bricks element between posts output by a query loop.
Categories:
Tags:
Pro
CSS Grid for Posts Element in Bricks

CSS Grid for Posts Element in Bricks

The "Posts" element in Bricks has "Grid" as the default layout but the actual CSS it applies on the page feels hacky with negative margins…
Categories:
Auto Responsive Grids in Bricks

Auto Responsive Grids in Bricks

This tutorial provides the CSS that can be pasted for automatic responsive grids in Bricks Builder. Posts element Each post will get a right padding…
How to display a Query Loop in 3 columns in Bricks

How to display a Query Loop in 3 columns in Bricks

This tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.
Categories:
Pro
Image Banner as Query Loop Posts Grid’s Last Item in Bricks

Image Banner as Query Loop Posts Grid’s Last Item in Bricks

In the comments section of How to Insert Element(s) Between Query Loop Posts in Bricks tutorial, a site member asked: This is fantastic! Is there…
Categories:
Tags:
Pro
Sticky Scrolling in Bricks Builder

Sticky Scrolling in Bricks Builder

Updated on 22 Apr 2024 This Pro tutorial provides the steps to fix elements in the viewport i.e., make them sticky while adjacent content in the section…
Categories:
Tags:
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
Slow Zoom Effect for Slides in Bricks

Slow Zoom Effect for Slides in Bricks

This Pro tutorial provides the steps to set up a slow zoom effect for slides of nestable slider element in Bricks. Step 1 Add a…
Categories:
Tags: