jolia
October 5, 2024, 7:02pm
1
Hey,
A new element is very useful and needed to display the “new” badge in the query loop. Currently, we have this feature only in the products element. But it cannot be used in query loop.
Please keep this in mind. Of course, this can be implemented as a dynamic data, which will be much better.
2 Likes
LouisC
October 16, 2024, 2:55pm
2
+1 on this feature, that would definitely be great to have a dynamic data filter to display new badges on post cards.
If anyone has a solution to do this another way I’m interested to know !
Maybe there is some workaround for now. Any idea guys?
HOSEIN
October 19, 2025, 7:27am
4
Hi @MartinWB ,
This feature was added since Bricks 1.11.1
You can use condition or {woo_product_badge_new} dynamic datafor it and control its timing in Bricks settings > WooCommerce (Here ).
Good luck
1 Like
LouisC
October 19, 2025, 9:12am
5
Hi,
I think the question was about using the time condition for non products elements (like displaying a new badge for blog posts).
HOSEIN
October 19, 2025, 10:38am
6
Hi @LouisC ,
Yes, maybe Anyway, no problem and you can use the code below. Add the code to the theme’s functions.php.
if (!defined('ABSPATH')) exit;
add_filter('bricks/conditions/options', function($options) {
$options['post_new_status'] = [
'key' => 'post_new_status',
'label' => esc_html__('Post new status', 'textdomain'),
'group' => 'post', // Use default Bricks Post group
'compare' => [
'type' => 'select',
'options' => [
'is' => esc_html__('Is', 'textdomain'),
'is_not' => esc_html__('Is not', 'textdomain'),
],
'placeholder' => esc_html__('Select status', 'textdomain'),
],
'value' => [
'type' => 'select',
'options' => [
'new' => esc_html__('New', 'textdomain'),
'not_new' => esc_html__('Not new', 'textdomain'),
],
'placeholder' => esc_html__('Select new status', 'textdomain'),
],
'description' => esc_html__('Check if post is new (within 2 days) or not.', 'textdomain'),
];
return $options;
});
add_filter('bricks/conditions/result', function($result, $condition_key, $condition) {
if ($condition_key !== 'post_new_status') return $result;
$is_new = (current_time('timestamp') - get_post_time('U', true)) <= (2 * DAY_IN_SECONDS);
$compare = $condition['compare'] ?? 'is';
$value = $condition['value'] ?? 'new';
return ($compare === 'is') ? ($value === 'new' ? $is_new : !$is_new) : ($value === 'new' ? !$is_new : $is_new);
}, 10, 3);
This code adds the desired condition to the default POST group of Bricks. You can change the number of days from 2 to whatever you want in the code.
I hope it is useful for you
1 Like
I know this one. But would love to use that in query loop so loop will only show new products. Because this {woo_product_badge_new} is not stored in database you cannot use that let say in meta query.