Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

Skip to main content

Hide Tabs with Conditional Logic

Conditional Logic works with any DOM elements. That means you can hide your tabs created by MB Tabs extension with MB Conditional Logic. This guide show you how to do that.

Basic

Because tabs aren't regular field or meta box so you have to use rwmb_outside_conditions filter to tell Conditional Logic to add this element. Imagine that you have created a meta box like this:

add_filter( 'rwmb_meta_boxes', function($meta_boxes) {
$meta_boxes[] = array(
'title' => 'MB Tabs 2',
'tabs' => array(
'bio' => 'Biography',
'interest' => 'Interest',
),
'tab_style' => 'box',
'fields' => array(
array(
'name' => 'Bio',
'id' => 'bio',
'type' => 'textarea',
'tab' => 'bio',
),
array(
'name' => 'Interest',
'id' => 'interest',
'type' => 'textarea',
'tab' => 'interest',
),
),
);

return $meta_boxes;
});

This will generate a meta box with two tabs Biography and Interest. And here is the HTML output:

<ul class="rwmb-tab-nav">
<li class="rwmb-tab-bio rwmb-tab-active" data-panel="bio"><a href="#">Biography</a></li>
<li class="rwmb-tab-interest" data-panel="interest"><a href="#">Interest</a></li>
</ul>

If you want to hide a tab, just add its class to rwmb_outside_conditions filter. For example, if I want to hide Interest tab when post format is aside, add these lines:

add_filter( 'rwmb_outside_conditions', function( $conditions ) {
$conditions['.rwmb-tab-interest'] = array(
'hidden' => array( 'post_format', 'aside' ),
);
return $conditions;
} );

This will tell Conditional Logic hide .rwmb-tab-interest selector when post_format is aside

Hide the first tab

In case you want to hide the first tab, you have to hide its tab pane also and show the next tab pane, this example shows you how to do that:

add_filter( 'rwmb_outside_conditions', function( $conditions ) {
$conditions['.rwmb-tab-bio, .rwmb-tab-panel-bio'] = array(
'hidden' => array( 'post_format', 'aside' )
);
$conditions['.rwmb-tab-panel-interest'] = array(
'visible' => array( 'post_format', 'aside' )
);
return $conditions;
} );