Skip to content

Documentation

Extensive Documentation for PowerPack & WooPack to help you with common questions and issues.

PowerPack

⌘K
  1. Home
  2. Docs
  3. PowerPack
  4. Modules
  5. Advanced Tabs
  6. How to remove tabs with no content?

How to remove tabs with no content?

If there are tabs that don’t have any content or rely on a shortcode that doesn’t render any content, you can hide those tabs dynamically using the code below:

// PowerPack Advanced Tabs: Do not render tabs if the tab content is empty.
add_filter( 'pp_tabs_items', function( $items, $settings ) {
  foreach ( $items as $key => $item ) {
    $content = do_shortcode( $item->content );
    $content = preg_replace( '/<p><\/p>/', '', $content );
    if ( empty( trim( $content ) ) ) {
       unset( $items[ $key ] );
    }
  }
  return array_values( $items );
}, 10, 2 );

You just need to insert this code into your current child theme’s functions.php file.

Row edge-slant Shape Decorative svg added to top

Lifetime Deal Event! Save up to 43% this Summer Sale!   Grab the Deal

×