6 Random Featured Posts in Alphabetical Order in Bricks

In the BricksLabs Facebook group a user asks:

I am looking for a solution where I can randomly choose a given number of posts (e.g., 6) with a specific meta value (e.g., featured) and then order by the title (ascending).

This Pro tutorial provides the steps to use the PHP query editor of Bricks to output x number of random posts in ascending order of post titles that each have a featured post meta value set to true (1).

Step 1

Using a plugin like ACF or Meta Box or otherwise, set up a boolean (true/false) post meta named say, featured.

Edit the selected posts of your desired post type and mark them as featured.

Step 2

Set up a query loop on a Block in Bricks.

Enable "Query editor (PHP)".


This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro