When I use dynamic data it fails. In this example acf_brand_attribute_is is a number field, but I have tried a taxonomy field and a php function. I can echo any of these versions out and perform calculations on them - so I think the data is good. It just isn’t being pulled into Bricks.
I’m unsure how to reproduce the problem, but is it possible that the query doesn’t work in the builder but does in the front end?
If this is not the case, please send temporary login credentials and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase.
I have what might be a similar problem. I might be wrong but In my case, I’m attempting to use the name. I create a custom Taxonomy using ACF named “country”. In this case, the query goes through If I manually type “Lebanon”. But IfI use a dynamic tag like {post_terms_country:plain} nothing happens. My next attempt was to use a php function to return the ID so I might try it in this field. That’s when I stumbled upon this post
As per my email reply, actually, the {acf_xxx} used in the taxonomy query is working well in the actual frontend.
Unfortunately, it does not work as expected in the builder.
Already recorded this in the bug tracker.
We will tackle this issue.
look like this is still not working in 1.12.3 version… my loop works when hardcodwd, but when I try a dynamic value it doesn’t.
note dynamic value is a custom defined in functions.php
add_filter( 'bricks/dynamic_data/render_content', 'render_category_root_in_content', 20, 3 );
add_filter( 'bricks/frontend/render_data', 'render_category_root_in_content', 20, 2 );
function render_category_root_in_content( $content, $post, $context = 'text' ) {
// If our tag doesn't appear in $content, bail early.
if ( strpos( $content, '{category_root}' ) === false ) {
return $content;
}
// Replace it with the actual root category value
$value = my_get_category_root_value();
$output = str_replace( '{category_root}', $value, $content );
return $output;
}
/**
* 4) The actual logic to retrieve your category root value
* Put your ancestor logic here. This is so we can reuse it in both filters.
*/
function my_get_category_root_value() {
// If not on a category archive, just return empty
if ( ! is_category() ) {
return '';
}
$current_cat = get_queried_object();
if ( ! $current_cat || empty( $current_cat->term_id ) ) {
return '';
}
$ancestors = get_ancestors( $current_cat->term_id, 'category' );
$root_id = ( ! empty( $ancestors ) ) ? end( $ancestors ) : $current_cat->term_id;
return $root_id;
sorry for the late response. Can you check if your {category_root} dynamic tag returns the correct value? You can try to output it in the basic text element, and you should see what it returns.
Also, can you give me a screenshot, or even better - a video with sound, or your query setup?
it is crazy to me that these type of variables like the root_category_id are NOT INCLUDED in the base brick plugin. the loop query function is super weak and this could be a killer tool if it was fully developped… too bad
my code in the end, works well. now using taxonomy filtering
/* Daixtech CATEGORY_ROOT function to get the category parent and children
START
*/
/**
* 1) Register the dynamic tag so it appears in Bricks’ dropdown.
*/
add_filter( 'bricks/dynamic_tags_list', 'register_category_root_tag' );
function register_category_root_tag( $tags ) {
$tags[] = [
'name' => '{category_root}',
'label' => 'Category Root ID',
'group' => 'Taxonomy', // or any group name you prefer
];
return $tags;
}
/**
* 2) Provide the value if user selects "{category_root}" from the dropdown.
*/
add_filter( 'bricks/dynamic_data/render_tag', 'render_category_root_tag', 20, 3 );
function render_category_root_tag( $tag, $post, $context = 'text' ) {
if ( '{category_root}' !== $tag ) {
return $tag; // Not our tag
}
// We'll just return a placeholder string for testing
// Return "root category" to confirm it’s being called.
return my_get_category_root_value();
}
/**
* 3) Ensure we also replace "{category_root}" if typed directly in content.
* (Like how your loop_index code calls render_loop_index_in_content)
*/
add_filter( 'bricks/dynamic_data/render_content', 'render_category_root_in_content', 20, 3 );
add_filter( 'bricks/frontend/render_data', 'render_category_root_in_content', 20, 2 );
function render_category_root_in_content( $content, $post, $context = 'text' ) {
// If our tag doesn't appear in $content, bail early.
if ( strpos( $content, '{category_root}' ) === false ) {
return $content;
}
// Replace it with the actual root category value
$value = my_get_category_root_value();
$output = str_replace( '{category_root}', $value, $content );
return $output;
}
/**
* 4) The actual logic to retrieve your category root value
* Put your ancestor logic here. This is so we can reuse it in both filters.
*/
function my_get_category_root_value() {
// If not on a category archive, just return empty
if ( ! is_category() ) {
return '';
}
$current_cat = get_queried_object();
if ( ! $current_cat || empty( $current_cat->term_id ) ) {
return '';
}
$ancestors = get_ancestors( $current_cat->term_id, 'category' );
$root_id = ( ! empty( $ancestors ) ) ? end( $ancestors ) : $current_cat->term_id;
return $root_id;
// below code to return name instead of id.
// You could return $root_id, or get the category object for the name/slug
// For example: return the root category NAME
//$root_term = get_term( $root_id, 'category' );
// return ( $root_term && ! is_wp_error( $root_term ) ) ? $root_term->name : '';
}
/* Daixtech function to get the category parent and children
END
*/