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.

🎃 🎃

⚡ HALLOWEEN FLASH SALE! Save up to 40% OFF  Claim Your Treats ➔

🎃 Wait! Your Halloween Savings Are Still Here!

You're about to miss our biggest sale of the year. Save up to 40% and secure unlimited site licenses before the Halloween sale ends.

×