Advanced Customisations

Below you’ll find advanced customisations that aren’t included in theme settings. These customisations can either be added to a child theme functions.php file or by using the plugin Code Snippets. If you’d like to add a function using Code Snippets:

  1. Install and active the plugin, Code Snippets.
  2. Go to SnippetsImport.
  3. Import the function provided in the form of a XML or JSON file. A XML or JSON file is provided with each function below. Right click and Save As to download.

Disable Sticky Header On Mobile

Disable the sticky header below `768px` or in the case of Polestar Premium, below the point that the Mobile Menu Collapse field is set to.

if ( ! function_exists( 'polestar_child_body_classes' ) ) :
function polestar_child_body_classes( $classes ) {
	$classes[] = 'mobile-header-ns';
  	return $classes;
}
endif;
add_filter( 'body_class', 'polestar_child_body_classes' );

Code Snippets Import File
Disable Sticky Header on Mobile Snippet

Disable Responsive Layout

Disable the responsive layout on mobile devices.

if ( ! function_exists( 'polestar_child_setup' ) ) :
function polestar_child_setup() {
	remove_action( 'wp_head', 'polestar_viewport_tag' );

	function polestar_child_custom_viewport_tag() { ?>
		<meta name="viewport" content="width=1280" />
	<?php }
	add_action( 'wp_head', 'polestar_child_custom_viewport_tag' );	
}
endif;
add_action( 'after_setup_theme', 'polestar_child_setup' );

Code Snippets Import File
Disable Responsive Layout on Mobile Devices Snippet

Disable Smooth Scroll

Disable Polestar's smooth scroll functionality.

if ( ! function_exists( 'polestar_child_body_classes' ) ) :
function polestar_child_body_classes( $classes ) {
  $classes[] = 'disable-smooth-scroll';
  return $classes;
}
endif;
add_filter( 'body_class', 'polestar_child_body_classes' );

Code Snippets Import File
Disable Smooth Scroll Snippet

Adjust Sticky Header Logo Scaling

The sticky header and logo scaling settings can be found at AppearanceCustomizeTheme SettingsHeader. If you’ve enabled these settings and would like to adjust the logo scaling, the following function can be used. The below function won’t work in Code Snippets and needs to be used in a child theme functions.php file.

if ( ! function_exists( 'polestar_child_logo_scaling' ) ) :
function polestar_child_logo_scaling( $scale ) {
	return 0.755;
}
add_filter( 'polestar_logo_sticky_scale', 'polestar_child_logo_scaling' );
endif;

0.755 is the default scaling. Edit this value to adjust the logo scaling.

Code Snippets Import File
Adjust Sticky Header Logo Scaling

Change Page Settings Defaults

Using the below function you can adjust the page settings defaults. For example, if you’d like to set new posts and pages to default to Layout: No Sidebar, you could use the following function:

if ( ! function_exists( 'polestar_child_alter_page_setting_defaults' ) ) :
function polestar_child_alter_page_setting_defaults( $defaults, $type, $id ) {
	$defaults['layout'] = 'no-sidebar';

	return $defaults;
}
endif;
add_filter( 'puro_page_settings_defaults', 'polestar_child_alter_page_setting_defaults', 15, 3 );

Code Snippets Import File
Change Page Settings Defaults Snippet

Disable Header Search Expanded Close

By default, the header search will close when clicking anywhere outside of it. This isn't ideal if you're using an Ajax search plugin. In that event, the following will help.

if ( ! function_exists( 'polestar_child_body_classes' ) ) :
function polestar_child_body_classes( $classes ) {
	$classes[] = 'disable-search-close';
  	return $classes;
}
endif;
add_filter( 'body_class', 'polestar_child_body_classes' );

Code Snippets Import File
Disable Header Search Expanded Close Snippet

The following customization will change the logo in the sticky header on scroll. Before starting, ensure a logo is added at CustomizeSite IdentityLogo.

Once you've imported the function into Code Snippets, the following values should be replaced.

Regular Logo Image URL: https://purothemes.com/wp-content/uploads/2016/10/puro-logo-100.png
Sticky Logo Image URL: https://purothemes.com/wp-content/uploads/2016/06/puro-logo-1.png
Image ALT tags: puro logo
Image maximum widths: max-width: 75px; You can either adjust the max-width value or remove the style tag: style="max-width: 75px;"

Finally, add the following to Customize > Additional CSS or Appearance > Custom 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;
}

Code Snippets Import File
Sticky Logo Snippet.

Don't Display the WooCommerce Mini-Cart if the Cart Is Empty

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

Code Snippets Import File
Don't Display the WooCommerce Mini-Cart if the Cart Is Empty

Last updated: 18/06/2021