Conditions with Dynamic Data and get_post_meta()

I don’t know if anyone would have any suggestions on this, but here goes.


Visual representation of what I’m trying in bricks.

I’m trying to use get_post_meta() inside of a condition to query if the bricks builder postmeta field _bricks_page_content_2 contains any value. If it doesn’t (e.g, if there is no bricks data for that page), then display the section with WordPress content inside. I have used json_encode() to convert the array that get_post_meta() returns into a JSON string, and have determined that when there is no bricks data for a page, json_encode() returns “” (when echoed onto the page using the code element). However, when I use “” or even nothing for the value field in the element condition, the element either never shows up (comparison operator ==) or always shows up (comparison operator !=).

Any ideas?

Hi, I think the {echo:…} function is used to output the result from a PHP function. You can create a separate function to query post meta.

1 Like

Hey, thanks! Perhaps that should have been obvious, but not to me. You’ve really helped me out a ton!