Support Forum
Support › Meta Box Conditional Logic › Conditional Logic and Tabs
I have created several tabs with your builder (I use Metabox AIO) and would like to show and hide them depending on what is selected in a check list. I've tried using conditional logic but it doesn't work with the tabs, what can I do? I read this but it didn't help me much: https://docs.metabox.io/hide-tabs-with-conditional-logic/
Hi,
Can you please share the code that creates tabs, custom fields and the code that shows/hides the tab? I see it still works on my site.
I did not use the code, I used the builder, shall I send the screenshots of the builder?
Hi,
The conditional logic for tabs is not supported in the builder for now. You can use the custom code in the article to show/hide the tab. Something like
add_filter( 'rwmb_outside_conditions', function( $conditions ) {
$conditions['.rwmb-tab-interest'] = array(
'hidden' => array( 'post_format', 'aside' ),
);
return $conditions;
} );
Thank you, I had already seen this code on the support page and it unfortunately did not clarify it for me.
I have a checkbox list with these values:
disable_first_blue_band: Disable First blue band
disable_second_content_section: Disable Second Content Section
disable_partner_section: Disable Partner Section
I would like to check
disable_second_content_section: Disable Second Content Section
would hide the tab:
Second Content Section
tab_4er7e4xyg9g
Could you provide me with an example closer to my specific case?
I can put the code above directly into the function.php right?
Hi,
The PHP code in the article only works with the checkbox
field, a simple field with a single value. Assume that the checkbox
field has the ID checkbox_wdpmzjmthr
, then the code to hide the tab would be
add_filter( 'rwmb_outside_conditions', function( $conditions ) {
$conditions['.rwmb-tab-tab_4er7e4xyg9g'] = array(
'hidden' => array( 'checkbox_wdpmzjmthr', 'disable_second_content_section' ),
);
return $conditions;
} );