Code Snippets: Display Tab Filter - rumspeed/simple-side-tab GitHub Wiki

Filter tab display value examples

Plugin filter: rum_sst_plugin_display_tab

Conditionally turn off the tab on the homepage

// filter the display_tab value to conditionally turn off the tab on the homepage
add_filter( 'rum_sst_plugin_display_tab', 'rum_sst_display_tab_filter_example_1', 10 , 1 );
function rum_sst_display_tab_filter_example_1( $display ) {

    if ( is_front_page() ) {
        $display = false;
    }

    return $display;
}

Turn tab off on multiple pages

// filter the display_tab value to conditionally turn off the tab on multiple pages
add_filter( 'rum_sst_plugin_display_tab', 'rum_sst_display_tab_filter_example_2', 10 , 1 );
function rum_sst_display_tab_filter_example_2( $display ) {
 
    // returns false when the Page displayed is any of the following
    //    post ID = 42
    //    post_name = "sample-page"
    //    post_title = "Privacy Policy"
    if ( is_page( array( 42, 'sample-page', 'Privacy Policy' ) ) ) {
        $display = false;
    }

    return $display;
}