I am hoping someone can help here. I have a JetEngine CPT created with a checkbox metafield, that metafield then has numerous checkbox options. I would like to show a certain element ONLY if a relevant checkbox has been clicked on the post page.
Ok, so, the post which Panag sugested helped me a little.
I’m using JetEngine and CCTs. That post helped me understand some things which led me to the below function. You just need to change the variables and white list it.
//
function get_refei_dieta_array($option) {
global $post, $wpdb;
$current_post_id = $post->ID;
$refei_dieta_data = $wpdb->get_var(
$wpdb->prepare(
"SELECT refei_dieta FROM wp_jet_cct_dietas WHERE cct_single_post_id = %d",
$current_post_id
)
);
if ($refei_dieta_data) {
// Deserializa o array de 'refei_dieta' para verificar os valores
$refei_dieta_array = maybe_unserialize($refei_dieta_data);
return in_array($option, $refei_dieta_array, true);
}
return false;
}
//
For those who use JetEngine, upvote and like the below post:
Hi all, this was bugging me for a while too - finally figured it out. In the article posted in the Bricks Academy there is a section titled: “How to compare dynamic data against the value”
Using Jetengine Checkboxes (set to Array) adding the :value to the checkbox field looks at the value of the key stored in the database and will show according to the values ‘contained’ in the array.