add_filter( 'generate_navigation_search_output', 'tu_remove_search_query' );
function tu_remove_search_query() {
printf( // WPCS: XSS ok, sanitization ok.
'<form method="get" class="search-form navigation-search" action="%1$s">
<input type="search" class="search-field" value="" name="s" title="%2$s" />
</form>',
esc_url( home_url( '/' ) ),
esc_attr_x( 'Search', 'label', 'generatepress' )
);
}
generatepress
generate press exclude categories from posts page
add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-3,-5,-23');
}
return $query;
}
To hide Uncategorized posts use -1
disable block editor in widgets
// disable block editor */
add_filter( 'use_widgets_block_editor', '__return_false' );
gp hide featured image
/* generatepress hide featured image on all PAGES */
.single .page-header-image-single, .page-header-image, .page-header-image-single {
display: none;
}
/* show featured image on all POSTS */
article.category-music-leaders div.page-header-image-single {display: inherit;}
change generatepress color palette
previous solution
// change gp color palette
add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' );
function tu_custom_color_palettes( $palettes ) {
$palettes = array(
'#351C4D', /* brand */
'#FEBF7B', /* accent */
'#FF7E5F', /* action */
'#765285', /* hover */
'#C1c1c1', /* light */
'#fe7b84', /* midtone */
'#000000', /* black */
'#FFFFFF', /* white */
);
return $palettes;
}
gp featured post excerpt length
// gp blog - featured post excerpt length
add_filter( 'excerpt_length', function( $length ) {
global $wp_query;
if ( 0 === $wp_query->current_post && !wp_is_mobile() ) {
// Set Length of first post on desktop
$length = 50;
} else {
// Set Length of other posts and all posts on mobile
$length = 20;
}
return $length;
}, 200);
empty cart in nav redirect to shop
// woo gp - navigation - empty cart redirect to shop
add_action( 'template_redirect', 'empty_cart_redirect' );
function empty_cart_redirect(){
if( is_cart() && WC()->cart->is_empty() ) {
wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
exit();
}
}
enqueue font awesome
/**
* Enqueue Font Awesome.
*/
add_action( 'wp_enqueue_scripts', 'tu_load_font_awesome' );
function tu_load_font_awesome() {
wp_enqueue_style( 'font-awesome', '//use.fontawesome.com/releases/v5.5.0/css/all.css', array(), '5.5.0' );
}
enqueue google fonts
/**
* Add Google Fonts to Generate Press
*/
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'Livvic' ] = array(
'name' => 'Livvic',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
$fonts[ 'Barlow Condensed' ] = array(
'name' => 'Barlow Condensed',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
$fonts[ 'Barlow Semi Condensed' ] = array(
'name' => 'Barlow Semi Condensed',
'variants' => array( '100', '100i', '200', '200i','300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i' ),
'category' => 'sans-serif'
);
return $fonts;
}
css reset generatepress / elementor
/* Custom CSS by Dave Foy - https://www.designbuildweb.co - [email protected] */
/* Use the same method of sizing elements as Elementor does */
body * {
box-sizing: border-box;
}
/* Fix for horizontal wiggle on iPhone with GeneratePress - thanks Lyle Chamney from http://snifflevalve.com/ */
html, body {
max-width: 100% !important;
overflow-x: hidden !important;
}
/* Elementor - set some default left and right padding on mobile - same as in GeneratePress */
.elementor-top-section.elementor-section-boxed > .elementor-container {
padding: 0 20px;
}
/* 1. Don't set padding if an Elementor library item is embdedded within another section via shortcode */
/* 2. Don't set padding if an Elementor library item is embdedded within a standard non-full width page */
.elementor-top-section .elementor-top-section.elementor-section-boxed > .elementor-container,
body:not(.full-width-content) .entry-content .elementor-top-section.elementor-section-boxed > .elementor-container {
padding: 0;
}
/* 3. Don't set padding if the section has a class of 'nopad' */
.elementor-top-section.elementor-section-boxed.nopad > .elementor-container {
padding: 0;
}
/* Make Elementor elements expand to fit the full available width. This is due to how Elementor puts padding all the way around columns */
.elementor-section-boxed .elementor-column-gap-default .elementor-row {
width: calc(100% + 20px);
margin-left: -10px;
margin-right: -10px;
}
.elementor-section-boxed .elementor-column-gap-narrow .elementor-row {
width: calc(100% + 10px);
margin-left: -5px;
margin-right: -5px;
}
.elementor-section-boxed .elementor-column-gap-extended .elementor-row {
width: calc(100% + 30px);
margin-left: -15px;
margin-right: -15px;
}
.elementor-section-boxed .elementor-column-gap-wide .elementor-row {
width: calc(100% + 40px);
margin-left: -20px;
margin-right: -20px;
}
.elementor-section-boxed .elementor-column-gap-wider .elementor-row {
width: calc(100% + 60px);
margin-left: -30px;
margin-right: -30px;
}