2nd Apr '24
/
0 comments

6 Random Featured Posts in Alphabetical Order in Bricks

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)".

Paste:

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 show data of a post whose ID is the value of a URL parameter in Bricks

How to show data of a post whose ID is the value of a URL parameter in Bricks

In the Bricks Facebook group, a user asks: Hey Everyone,I am trying to create the following:1- I have a Custom Post Type2- I have a…
Categories:
Displaying SureCart Featured Products & Products Collections with a Query Loop

Displaying SureCart Featured Products & Products Collections with a Query Loop

We walk through how to use a query loop to display SureCart products, featured products & collections.
Categories:
Pro
ACPT Gallery Field Query Loop in Bricks

ACPT Gallery Field Query Loop in Bricks

How we can output images from ACPT‘s Gallery field for posts as a grid using a query loop.
Categories:
Pro
Alternating Posts from Two Post Types in Bricks

Alternating Posts from Two Post Types in Bricks

How to output posts from two seperate post types, alternating in a query loop.
Categories:
Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
Adding any Custom WP_Query loop to Bricks’ Query Loop

Adding any Custom WP_Query loop to Bricks’ Query Loop

Sometimes we may need to create a custom post loop using Bricks' query loop feature, but wish to use our own WP_Query code for more…