Skip to content

Instantly share code, notes, and snippets.

View REMspacing-Tyopgraphy.css
/* Experimental basic REM spacing and typography */
html {
font-size: 18px;
}
@media(max-width: 768px) {
html {
font-size: 16px;
}
@diggeddy
diggeddy / GP + Perfmatters No Lazy on logos
Created Aug 3, 2020
Add no-lazy class to GP logos to exclude perfmatters lazy loading
View GP + Perfmatters No Lazy on logos
add_filter( 'generate_mobile_header_logo_output', function( $output ) {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return $output;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
@diggeddy
diggeddy / GP - Floating Post Navigation
Last active Jun 4, 2020
Add floating post navigation using GP Hook Element
View GP - Floating Post Navigation
// HTML and PHP
// This is hooked into after_header hook with execute PHP
<div class="floating-post-nav">
<div class="float-link prev">
<?php previous_post_link('%link', '%title', true ); ?>
<div class="floating-arrow">
<svg aria-hidden="true" role="img" height="1em" width="1em" viewbox="0 0 256 512" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"></path></svg>
</div>
</div>
View WooCategoryNavigation.php
<?php
$cat_args = array(
'orderby' => 'name',
'order' => 'asc',
'hide_empty' => true,
);
$product_categories = get_terms( 'product_cat', $cat_args );
if ( ! empty( $product_categories ) ) {
@diggeddy
diggeddy / NicheWooGalleryStack.php
Created Apr 20, 2020
GeneratePress - WOO Stacked Image Gallery for Single Product
View NicheWooGalleryStack.php
<div class="woo-sumamry-wrap"><!-- open wrap -->
<div class="woo-gallery-stack hide-on-mobile">
<?php
global $product;
// Get post product thumbnail
if ( has_post_thumbnail( $product->get_id() ) ) {
$attachment_ids[0] = get_post_thumbnail_id( $product->get_id() );
$attachment = wp_get_attachment_image_src( $attachment_ids[0], 'full' );
$attachment_alt = get_post_meta( $attachment_ids[0], '_wp_attachment_image_alt', TRUE);
@diggeddy
diggeddy / Woocommerce Gallery Thumbnail Sizes
Created Mar 20, 2020
Increase Gallery thumb size and reduce columns from 4 x 100px to 3 x 250px
View Woocommerce Gallery Thumbnail Sizes
@diggeddy
diggeddy / attachment.php
Last active Oct 29, 2019
Simple attachment.php for GeneratePress
View attachment.php
<?php
/**
* The Template for displaying all attachments.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@diggeddy
diggeddy / SimpleAuthorBoxShortcode.php
Last active Sep 4, 2019
Create a simple author box shortcode
View SimpleAuthorBoxShortcode.php
<?php
// Simple Author Box Shortcode
add_shortcode( 'db_author_box', 'db_author_box_shortcode' );
function db_author_box_shortcode() {
ob_start();
// Check if is Single Post
if ( is_single() ) {
@diggeddy
diggeddy / Register Custom Taxonomy for Element Cotnrols
Last active Sep 1, 2021
Add custom taxonomy specifically for GP Element Display Rules
View Register Custom Taxonomy for Element Cotnrols
<?php
/**
* Generate custom taxonomy for Element Display Rules
*
* Custom Taxonomy titled Element Controls on Posts and Pages
* Add your own Element Control Terms
* used solely for setting Element Display Rules
*/
function element_control_custom_tax() {
View GP Site - Niche CSS
/*-- Navigation --*/
.main-navigation {
box-shadow: 0 2px 2px -2px rgba(0, 0, 0, .2);
}
.navigation-search {
background-color: #fff;
}