If we add a custom field to posts or CPT using Jet Engine or even WordPress custom field and use it to dynamically control the rating value, it works well in the front end, but in the rendering builder can’t. It works well for products ({woo_product_rating:value}) and there are no problems.
just like @Patric said, it should be working. I’ve also tested locally, and it works. Was with ACF field, but this should not make a difference.
You said that you were able to replicate it on a try.bricksbuilder. Do you have a page where I can see this?
The problem is with the own dynamic tag. My dynamic tag is selfmade and it seems something does not work anymore with the rating element and a selfmade tag:
Don’t know why yet. But if I change the selfmade dynamic tag to a function ({echo:…}), then the rating element works again.
If I create two dynamic data codes in the same function, then the dynamic code does not work anymore in the rating element.
If I just create one dynamic data code, then the dynamic code works in the rating element.
Is there a mistake in my code?
function render_kkstar_rating( $content, $post, $context = 'text' ) {
// $content might consists of HTML and other dynamic tags
// Only look for dynamic tag {my_dd_tag}
if ( strpos( $content, '{kk_star_rating}' ) === false && strpos( $content, '{chochete_url}' ) === false ) {
return $content;
}
switch (true) {
case strpos( $content, '{kk_star_rating}' ):
$my_value = run_rating_dd_tag_logic();
$content = str_replace( '{kk_star_rating}', $my_value, $content );
break;
case strpos( $content, '{chochete_url}' ):
$my_value = run_chocheteurl_dd_tag_logic();
$content = str_replace( '{chochete_url}', $my_value, $content );
break;
}
return $content;
}
because this code with only one dynamic data works:
function render_kkstar_rating( $content, $post, $context = 'text' ) {
// $content might consists of HTML and other dynamic tags
// Only look for dynamic tag {my_dd_tag}
if ( strpos( $content, '{kk_star-rating}' ) === false ) {
return $content;
}
// Do your custom logic here, you should define run_my_dd_tag_logic() function
$my_value = run_rating_dd_tag_logic();
// Replace the tag with the value you want to display
$content = str_replace( '{kk_star-rating}', $my_value, $content );
return $content;
}
The dynamic data code works in the title element, it only does not work in the rating element.
Must be something wrong in my case statement? Just curious why it worked before the latest version of Bricks and still works to print out the value. Just the rating element does not work anymore.