Skip to content

Instantly share code, notes, and snippets.

View carlosvarela's full-sized avatar

Carlos Varela carlosvarela

View GitHub Profile
@samkent
samkent / wordpress_page_template_body_class.php
Last active June 28, 2018 19:27
WordPress add body class if page template
<?php
/**
* Add a custom body class for a specific page template
* Add the following to your theme functions.php file.
*/
add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
if ( is_page_template( 'templates/page-contact.php' ) ) {
$classes[] = 'contact';
}
@DevinWalker
DevinWalker / woocommerce-optimize-scripts.php
Last active January 8, 2024 13:24
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );