Condition not working with function as expected

Hi,

I’m trying to use a condition to show or hide a sidebar, depending upon the value returned from a function. At the moment, the function simply returns the string ‘show’:

function sidebar_display()
{
    return 'show';
}

If I echo this function in a code block it shows the return value, as expected:

However, when I try to use this in a condition on my “sidebar” block, the content is not showing on the front end, where I would expect it to display:

image

Am I missing something really obvious? Any help would be gratefully received.

Thanks

Have you tried the equal to operator instead of contains?

Hi Sridhar,

Thanks for the reply - I have tried the “==” operator, but unfortunately it still doesn’t work.

Hey Duncan,

did you allow your function to be used with the dynamic data echo tag?

add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'sidebar_display',
  ];
} );

Best,

André

Hey André,

That was it! I’d forgotten about that step - now that I’ve added it in, the condition is working.

Thanks for the speedy reply.