Skip to content

Instantly share code, notes, and snippets.

@generatepress
generatepress / gist:53add6a3115a586e06004a6d453cf8b6
Created August 31, 2018 18:19
Code causing conflict with Beaver Themer
add_action( 'woocommerce_before_shop_loop', 'generatepress_wc_before_shop_loop' );
/**
* Add opening element inside shop page.
*
* @since 1.3
*/
function generatepress_wc_before_shop_loop() {
$classes = apply_filters( 'generate_woocommerce_container_classes', array(
'wc-columns-' . generatepress_wc_get_setting( 'columns' ),
//'wc-tablet-columns-' . generatepress_wc_get_setting( 'tablet_columns' ),
@generatepress
generatepress / gist:fae398a39bb8802364e623836941eab4
Created August 16, 2018 02:31
Apply the GPP smooth scroll to all hash links.
add_filter( 'generate_smooth_scroll_elements', function( $elements ) {
$elements[] = 'a[href*="#"]';
return $elements;
} );
@generatepress
generatepress / gist:c270163b367cc7009a2b217094e861f6
Last active August 6, 2018 17:44
Example of generate_{element}_element_display filter. In this example we target author archives and an Element with the ID of 10.
add_filter( 'generate_header_element_display', function( $display, $element_id ) {
if ( 10 === $element_id && is_author() ) {
$display = false;
}
return $display;
}, 10, 2 );
@generatepress
generatepress / archive-{post_type}.php
Last active November 2, 2018 20:54
Remove links from title in post type archive
<?php
/**
* The template for displaying Archive pages.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@generatepress
generatepress / gist:9f99bbfa532ea4f9eafb6bd238b8cc9a
Created June 12, 2018 20:13
CSS for adding site title to navigation
.main-navigation .site-branding {
float: left;
}
.main-navigation .site-branding a {
line-height: 60px;
font-size: 20px;
}
add_action( 'after_setup_theme', 'tu_navigation_as_header' );
function tu_navigation_as_header() {
remove_action( 'generate_header', 'generate_construct_header' );
add_action( 'generate_inside_navigation', 'tu_site_title_navigation' );
}
function tu_site_title_navigation() {
?>
<div class="site-branding">
<p class="main-title" itemprop="headline">
@generatepress
generatepress / gist:2d037a5a7341ffc67c6af1a056b54e34
Created June 7, 2018 15:51
Remove Google Fonts from the Customizer
add_action( 'admin_init', 'tu_remove_google_fonts' );
function tu_remove_google_fonts() {
add_filter( 'generate_google_fonts_array', '__return_false' );
}
@generatepress
generatepress / gist:38a00e43abb9a758c14a5e07ffbee0b3
Created May 31, 2018 17:33
Add the page header image to WooCommerce
add_action( 'wp', 'tu_add_page_header_image_woocommerce', 60 );
function tu_add_page_header_image_woocommerce() {
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
add_action( 'generate_before_content', 'generate_page_header' );
}
}
<script>
var hamburger = document.querySelector(".hamburger"),
menuToggle = document.querySelector( '.menu-toggle' ),
menuItems = document.querySelectorAll( 'nav ul a' ),
closeElements = document.querySelectorAll( '.slideout-overlay, .slider-exit a' );
menuToggle.addEventListener("click", function() {
hamburger.classList.toggle("is-active");
} );
<?php
/**
* The template for displaying posts within the loop.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}