skip to Main Content

Hide Top Bar Social on Small Devices

The following snippet can be used if you wish to hide the top bar social icons on small (mobile) devices. It works by hooking into the "wpex_topbar_social_class" filter and modifying the classes to add a hidden class at your defined top bar breakpoint.

/**
 * Alter the top bar classes.
 *
 * @link https://total.wpexplorer.com/docs/snippets/hide-top-bar-social-on-small-devices/
 */
add_filter( 'wpex_topbar_social_class', function( $class ) {

	// Get breakpoint at which the top bar becomes centered as defined in the Customizer
	$breakpoint = TotalTheme\Topbar\Core::breakpoint();

	// Add custom classes to hide top bar social on small devices
	$class[] = 'wpex-hidden wpex-' . sanitize_html_class( $breakpoint ) . '-block';

	// Return class
	return $class;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)
Back To Top