11th Dec '24
/
0 comments

Filtering posts by a group field’s subfield value with Meta Box when using a custom table in Bricks

In the comments section of Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks tutorial, a member asks:

Do you have a tutorial for how true/false works in a custom database table with metabox?

I use custom database table for faster queries.

Make a select field and and two options YES and NO.

then go to settings tab in the custom field area in metabox and...

enable > "save data in a custom table"enable > "include table prefix"enable > "create table automatically"

Then fill in custom table > "my_product_details"Then fill in custom prefix > "my_prefix_".

Then in bricks go query products and go add add below in meta query:key > mb_product_product_detail_latest_productvalue > 1

"mb_product" references to metabox product post type.Then "product_detail_" is the table prefix.Then "latest_product" is the field ID.

But whatever I do, it doesn't query.

I tried without mb_product. With brackets around it. Nothing works.

This Pro tutorial provides the steps to filter the posts of a Bricks query loop to output only those with the value of a Select subfield of a Group field set to Yes when using a custom table in Meta Box.

Consider this scenario:

Field Group name: Product Fields

Settings: Location is Post type = Product (product)

Product Detail (group type field)|__Latest Product (select type field with Yes and No choices. You may want to set Placeholder to -- Select --)

In the Settings tab:

For products titled "WordPress Pennant" and "T-Shirt with Logo":

For other products either the value is set to No or not set.

After implementing the tutorial, output of a query loop:

Step 1

[optional] If you want to output the value of the 'Latest Product' select subfield on single products, add this in a Code element:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

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…
Pro
Related Posts by Taxonomy in Bricks

Related Posts by Taxonomy in Bricks

In the previous Posts Related by Current Post's Terms in Bricks tutorial, we showed how posts related to the current single post that have the…
Categories:
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:
Pro
Nav Menus Custom Query Types in Bricks

Nav Menus Custom Query Types in Bricks

Updated on 21 Aug 2024 This Pro tutorial shows how custom query types for each navigation menu can be generated in Bricks. This enables us…
Pro
Meta Box Related Project’s Featured Image URL on Single Reviews

Meta Box Related Project’s Featured Image URL on Single Reviews

Updated on 26 Jun 2025 In a recent website I worked on, a requirement was to get the URL of the featured image of a…
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
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags: