NO BUG: Dynamic Data causing errors in PHP Query Loop Builder

Browser: Chrome 110
OS: macOS / Windows / Linux / etc.

I have two Metabox CPTs:

  • 'testimonial' (Testimonails)
  • 'lp' (Landing Pages)

In 'lp' I have a Post custom field ‘linked_testimonial’ which is used to create a one-way relationship between a particular section of the 'lp' template and the ‘testimonial’ chosen to display in that section.

(Using a Post custom field gives me greater control over displaying a particular testimonial in a particular part of a template vs using the limited Bricks/MB integrated query for an entire set of testimonials linked via the usual bi-directional relationship)

In the section of the template that I’m trying to display the relevant testimonial, I attempt to query the testimonial in order to get access to its custom fields like so:

return [
  'post_type' => 'testimonial',
  'post__in' => {linked_testimonial:value},
  ];
return [
  'post_type' => 'testimonial',
  'p' => {linked_testimonial:value},
  ];
$post_id = rwmb_meta( 'linked_testimonial' );
$post     = get_post( $post_id );

return [
  'post_type' => 'testimonial',
  'post__in' => $post,
  ];

But both of these attempts return an Error in the builder.

When I test outputting {linked_testimonial} in the builder in a basic text element, it returns an HTML <a> link (as expected) until I add a :value suffix to it like {linked_testimonial:value} which outputs exactly what I want: the post ID of the linked testimonial in plaintext.

However, that must not be the case in the PHP Query Builder because it keeps throwing an Error or sometime even a parserError when I try different things to query the value of that dynamic data.

What am I missing?

UPDATE: I got my intended query to work using:

$post_id = rwmb_meta( 'linked_testimonial' );

return [
  'post_type' => 'testimonial',
  'p' => $post_id,
  'posts_per_page' => 1,
  ];

However, leaving this open because the DD behavior in the PHP query builder is still shifty to me.

Hi @michaelkern ,

Thanks for checking with us.

Each dynamic tag in Bricks has a different default behavior.

For your linked_testimonial field (Post), the default output will be the selected Post title wrapped in <a> tag and linked to the post URL.

Since 1.8, we introduced :value filter so you can use it more flexibly.

You will get the same output in Query Editor or Code element.

If you are using ‘post__in’, you should ensure the value is array.
post__in expecting array value

Example:

return [
  'post_type' => 'testimonial',
  'post__in' => [ '{linked_testimonial:value}'],
  ];

For this, it should work, I tried locally without issue.

return [
  'post_type' => 'testimonial',
  'p' => {linked_testimonial:value},
  ];

Regards,
Jenn