Grid Variation Options

Set different column counts for desktop, tablet and mobile on grid blocks.

Lauren Gray Avatar

Grid Variation Options lets you set a different number of columns for desktop, tablet and mobile on Group and Post Template blocks that use a grid layout. You pick the numbers with sliders in the block sidebar, so there are no CSS classes to remember.

Before you start

  • WordPress 5.8.3 or later
  • PHP 5.6 or later

Install

  1. In your WordPress dashboard, go to Plugins → Add New Plugin.
  2. Click Upload Plugin.
  3. Choose the plugin zip file.
  4. Click Install Now.
  5. Click Activate.

How to use

Add a grid with the Grid variation

  1. Open a post, page or template in the block editor.
  2. Open the block inserter and add the Grid block (it’s a variation of the Group block, described as “Arrange blocks in a grid.”).
  3. Add your content inside it.

A new Grid block starts with the per-device column fields empty, so it uses the column setting from the block’s Layout options until you set them. Set them in the block sidebar (next section).

Set columns per device

  1. Select a Group block or a Post Template block (inside a Query Loop) whose layout is set to grid.
  2. In the block sidebar, open the Grid panel.
  3. Set Desktop Columns, Tablet Columns and Mobile Columns. Each one takes a number from 1 to 12, typed in or set with the slider.
  4. Save or update the post.

The Grid panel only appears when the block’s layout is a grid. If you don’t see it, switch the block’s layout to grid first.

Heads up: the panel shows the reminder “Any settings you configure here will overwrite the layout section.” The column counts you set here win over the column setting in the block’s regular Layout options. Leave a device empty and that screen size falls back to the Layout section.

Use the CSS classes directly

The sliders work by adding classes to the block’s Additional CSS class(es) field. You can type them yourself if you prefer, on any Group or Post Template block with a grid layout:

  • Desktop: desktop-grid-repeat-1 through desktop-grid-repeat-12
  • Tablet: tablet-grid-repeat-1 through tablet-grid-repeat-12
  • Mobile: mobile-grid-repeat-1 through mobile-grid-repeat-12

For example, desktop-grid-repeat-3 tablet-grid-repeat-2 mobile-grid-repeat-1 gives you three columns on desktop, two on tablet and one on mobile.

Settings

Go to Settings → Grid Variation Options to change the screen widths that count as each device. Each field is the minimum screen width, in pixels.

  • Desktop: screens this wide or wider use your desktop columns. Default: 1024.
  • Tablet: screens this wide or wider (up to just under the desktop width) use your tablet columns. Default: 781.

Anything narrower than the Tablet width uses your mobile columns. Click Save Changes when you’re done. Only administrators can save these settings.

Developer reference

Coming soon: the hooks, filters and functions you can use with this plugin from your theme or a code snippet.

FAQs