add_filter( 'woocommerce_account_menu_items', 'snippetpress_remove_empty_downloads_link' ); function snippetpress_remove_empty_downloads_link( $items ) { if (!is_admin()){ $downloads = WC()->customer->get_downloadable_products(); $has_downloads = (bool) $downloads; if ( !$has_downloads) { unset($items['downloads']); } } return $items; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter