Polestar

Advanced Customisations

3 min read Updated Sep 2026 Polestar

These code snippets change Polestar behavior that has no Customizer setting. Add them to a child theme functions.php file or use the Code Snippets plugin.

Add a Snippet With Code Snippets

  1. Install and activate Code Snippets.
  2. Go to SnippetsAdd New and paste the code. Or go to SnippetsImport and upload the import file linked under a snippet.
  3. Save the snippet and activate it.

Disable Sticky Header on Mobile

Stops the header from sticking below 768px. With Polestar Premium, it stops below the Mobile Menu Collapse value.

function polestar_child_mobile_header_class( $classes ) {
	$classes[] = 'mobile-header-ns';
	return $classes;
}
add_filter( 'body_class', 'polestar_child_mobile_header_class' );

Import file

Disable Responsive Layout

Sets a fixed 1280px viewport so phones show the desktop layout.

function polestar_child_viewport_tag() {
	echo '<meta name="viewport" content="width=1280" />';
}

function polestar_child_setup() {
	remove_action( 'wp_head', 'polestar_viewport_tag' );
	add_action( 'wp_head', 'polestar_child_viewport_tag' );
}
add_action( 'after_setup_theme', 'polestar_child_setup' );

Import file

Disable Smooth Scroll

Turns off the smooth scroll for menu links to anchors on the same page.

function polestar_child_smooth_scroll_class( $classes ) {
	$classes[] = 'disable-smooth-scroll';
	return $classes;
}
add_filter( 'body_class', 'polestar_child_smooth_scroll_class' );

Import file

Adjust Sticky Header Logo Scaling

Changes how far the logo shrinks when the header sticks. Turn on Sticky Header Scales Logo at AppearanceCustomizeTheme SettingsHeader first. The default scale is 0.775.

function polestar_child_logo_scaling( $scale ) {
	return 0.7;
}
add_filter( 'polestar_logo_sticky_scale', 'polestar_child_logo_scaling' );

Import file

Change Page Settings Defaults

Changes the starting values of the Page Settings. This example sets new posts and pages to the No Sidebar layout.

function polestar_child_page_setting_defaults( $defaults, $type, $id ) {
	$defaults['layout'] = 'no-sidebar';
	return $defaults;
}
add_filter( 'puro_page_settings_defaults', 'polestar_child_page_setting_defaults', 15, 3 );

The keys and values are:

  • layout: default, no-sidebar, full-width-no-sidebar, constrained or stripped.
  • overlap: disabled, enabled, light or dark.
  • page_title, header_margin, footer_margin and footer_widgets: true or false.

Import file

Disable Header Search Expanded Close

The open header search closes when a visitor clicks outside it. Turn this off when you use an Ajax search plugin.

function polestar_child_search_close_class( $classes ) {
	$classes[] = 'disable-search-close';
	return $classes;
}
add_filter( 'body_class', 'polestar_child_search_close_class' );

Import file

Sticky Logo

Swaps the logo when the header sticks. It works with the logo set at AppearanceCustomizeSite IdentityLogo. Leave Theme Settings > Header > Logo empty, because that logo takes priority and skips this filter.

Replace the two image URLs, the alt text and the max-width value with your own.

function polestar_child_sticky_logo( $html ) {
	$html = preg_replace(
		'/<img(.*?)\/>/',
		'<img class="alt-logo" style="max-width: 75px;" src="https://example.com/wp-content/uploads/logo.png" alt="Northfield Studio" /><img class="alt-logo-scroll" style="max-width: 75px;" src="https://example.com/wp-content/uploads/logo-small.png" alt="Northfield Studio" />',
		$html
	);
	return $html;
}
add_filter( 'get_custom_logo', 'polestar_child_sticky_logo' );

Then add this CSS at AppearanceCustomizeAdditional CSS:

.stuck.site-header .site-branding .alt-logo {
	display: none;
}

.site-header .site-branding .alt-logo-scroll {
	display: none;
}

.stuck.site-header .site-branding .alt-logo-scroll {
	display: block;
}

Import file

Hide the Mini Cart When the Cart Is Empty

Uses the polestar_display_mini_cart filter. The default hides the mini cart on the cart and checkout pages only.

add_filter( 'polestar_display_mini_cart', function( $status ) {
	if ( is_cart() || is_checkout() || ! WC()->cart ) {
		return false;
	}
	return ! WC()->cart->is_empty();
} );

Import file