.main-navigation .main-nav ul li[class*="current-menu-"] > a:after{
position: absolute;
bottom: calc(50% - 1.5em);
height: 0;
width: 0;
left: -webkit-calc(50% - 8px);
left: calc(50% - 10px);
border: 9px solid rgba(0,0,0,0);
border-bottom-color: currentcolor;
content: "";
}
GeneratePress
GeneratePress – auto close mobile menu when scrolling
<script>
document.addEventListener( 'scroll', function( e ) {
const openedMenus = document.querySelector( '#mobile-header' );
const btn = openedMenus.querySelector( 'button.menu-toggle' );
if(openedMenus.classList.contains('toggled')){
btn.click();
}
} );
</script>
GeneratePress – adding smooth scroll to all anchor links
add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
$elements[] = 'a[href*="#"]';
return $elements;
} );
GeneratePress Elements Header
Custom Fields
{{custom_field._thumbnail_id}}
GeneratePress Excerpt Shortcode
function db_page_hero_excerpt() {
ob_start();
global $post;
if ( has_excerpt( $post->ID ) ) {
?>
<div class="page-hero-excerpt">
<?php echo the_excerpt(); ?>
</div>
<?php
}
return ob_get_clean();
}
add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );
Schortcode: [page_hero_excerpt]
GeneratePress body backgound image with overlay
body {
background:
/* Update the RGBA value with your own */
linear-gradient(
rgba(255, 0, 0, 0.45),
rgba(255, 0, 0, 0.45)
),
url(URL TO YOUR IMAGE);
}
GeneratePress Elements in Adminbar
add_action('admin_bar_menu', 'add_toolbar_items', 100);
function add_toolbar_items($admin_bar){
$admin_bar->add_menu( array(
'id' => 'mw-gp-elements',
'title' => 'GP Elements',
'href' => '/wp-admin/edit.php?post_type=gp_elements',
'meta' => array(
'title' => __('GP Elements'),
),
));
$admin_bar->add_menu( array(
'id' => 'mw-gp-block',
'parent' => 'mw-gp-elements',
'title' => 'New GP Block',
'href' => '/wp-admin/post-new.php?post_type=gp_elements&element_type=block',
'meta' => array(
'title' => __('New GP Block'),
'class' => 'mw-gp-elements-adminbar'
),
));
$admin_bar->add_menu( array(
'id' => 'mw-gp-header',
'parent' => 'mw-gp-elements',
'title' => 'New GP Header',
'href' => '/wp-admin/post-new.php?post_type=gp_elements&element_type=header',
'meta' => array(
'title' => __('New GP Header'),
'class' => 'mw-gp-elements-adminbar'
),
));
$admin_bar->add_menu( array(
'id' => 'mw-gp-hook',
'parent' => 'mw-gp-elements',
'title' => 'New GP Hook',
'href' => '/wp-admin/post-new.php?post_type=gp_elements&element_type=hook',
'meta' => array(
'title' => __('New GP Hook'),
'class' => 'mw-gp-elements-adminbar'
),
));
$admin_bar->add_menu( array(
'id' => 'mw-gp-layout',
'parent' => 'mw-gp-elements',
'title' => 'New GP Layout',
'href' => '/wp-admin/post-new.php?post_type=gp_elements&element_type=layout',
'meta' => array(
'title' => __('New GP Layout'),
'class' => 'mw-gp-elements-adminbar'
),
));
}
Generatepress Remove Google Fonts
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'generate-fonts' );
} );
Remove Google Fonts from Customizer too
add_action( 'admin_init', function() {
add_filter( 'generate_google_fonts_array', '__return_empty_array' );
} );
GeneratePress set Widget Title to p
add_filter( 'generate_start_widget_title', function() {
return '<p class="widget-title">';
} );
add_filter( 'generate_end_widget_title', function() {
return '</p>';
} );
GeneratePress: Menu Underline Effects
@media (min-width: 769px) {
.main-navigation .menu > .menu-item > a::after {
content: "";
position: absolute;
right: 0;
left: 50%;
bottom: 15px;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
display: block;
width: 0;
height: 2px;
background-color: currentColor;
transition: 0.3s width ease;
}
.main-navigation .menu > .menu-item.current-menu-item > a::after,
.main-navigation .menu > .menu-item.current-menu-ancestor > a::after,
.main-navigation .menu > .menu-item > a:hover::after {
width: 50%;
}
}