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 630 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:
Pro
Dynamic Horizontal Posts Accordion in Bricks

Dynamic Horizontal Posts Accordion in Bricks

Update on 8 Sep 2024: You may want to follow the newer version that considers accessibility. Looking to make a Horizontal Image Accordion dynamic? This…
Pro
WordPress Posts using WP REST API in Bricks

WordPress Posts using WP REST API in Bricks

The steps to display posts from any WordPress site that has WP REST API enabled in Bricks builder using a custom query type.
Categories:
Pro
Masonry Accordion Query Loops in Bricks Builder

Masonry Accordion Query Loops in Bricks Builder

Learn how to enable masonry layout for nestable accordions in Bricks builder and use JavaScript to re-layout the masonry on accordions' open and close.
Categories:
Tags:
Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

Querying Posts by Date Field to Exclude Past Events with ACPT Plugin

In the Bricks' Facebook group, a user asked: Meta query? What am I missing?Hi all, really need a little guidance on this one. I have…
Categories:
Filtering Bricks Posts Query Loop by Meta Box Group’s Radio Subfield Value

Filtering Bricks Posts Query Loop by Meta Box Group’s Radio Subfield Value

In the past we showed how a Bricks posts query loop can be filtered by Meta Box group's subfield of types text/number and Datepicker here.…
Categories:
Pro
Hierarchical Posts with Nested Query Loops in Bricks

Hierarchical Posts with Nested Query Loops in Bricks

Learn how to set up nested query loops in Bricks to show hierarchical posts with child posts grouped under their corresponding parent posts
Categories:
Pro
Categories and SubCategories Query Loop Tabs in Bricks

Categories and SubCategories Query Loop Tabs in Bricks

Learn how to show top-level parent categories as tab titles and the corresponding subcategories as tab contents using Bricks nested queries.
Categories: