SOLVED: Show or hide an element based on php function

Hi everyone,

I just wrote a small php function which checks if the week is odd or even. And my idea is to show an element based on that.

Like this:

I run the php as a code snippet.

Currently, I’m struggling to get is work with the Bricks “conditions” option. Does someone know how to fix it?

Thanks in advance.

Hi

You have to use {echo:your_function_name()}

as explained in the Bricks academy

Advanced: echo

Bricks 1.4 introduces the echo tag to render the output of any PHP function:

{echo:my_custom_function} – Echoes the value of the PHP function my_custom_function()

It accepts arguments, with or without single quotes, like so:
{echo:get_the_date('Y-m-d', 55)} – Echoes the date of the post 55 formatted to Y-m-d

Please note that the echo tag does not support double quotes and the custom PHP function should return the value (do not echo the value inside of the custom function).

Thanks, @Patric! I overlooked it.