Skip to content

Instantly share code, notes, and snippets.

@nathanrice
nathanrice / functions.php
Created August 31, 2015 14:59
Remove entry meta for post types
<?php
add_action( 'init', 'sample_remove_entry_meta', 11 );
/**
* Remove entry meta for post types
*
* @link https://gist.github.com/nathanrice/03a5871e5e5a27f22747
*/
function sample_remove_entry_meta() {
remove_post_type_support( 'post-type', 'genesis-entry-meta-before-content' );
@nathanrice
nathanrice / formatting.php
Created June 20, 2016 14:44
Account for a desired 0 characters in content limit
function genesis_truncate_phrase( $text, $max_characters ) {
if ( ! $max_characters ) {
return '';
}
$text = trim( $text );
if ( mb_strlen( $text ) > $max_characters ) {
@nathanrice
nathanrice / functions.php
Created January 6, 2016 16:41
Add back blogPosting Schema to Genesis sites
<?php
/*
Add back Schema.org/blogPosting microdata to post entries.
Replace all instances of "themedemo" with something unique to your site.
User input is required in the last function. Be sure to fill these fields in with your own information.
Instances where you need to fill in information will be marked with a comment that indicates so.
*/
@nathanrice
nathanrice / functions.php
Created May 28, 2015 16:33
Enable Genesis Accessibility
//* Add Accessibility support
add_theme_support( 'genesis-accessibility', array( 'headings', 'drop-down-menu', 'search-form', 'skip-links' ) );
@nathanrice
nathanrice / style.css
Created May 28, 2015 16:34
Style new Genesis Accessibility output
/* ## Screen reader text
--------------------------------------------- */
.screen-reader-text,
.screen-reader-text span,
.screen-reader-shortcut {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
@nathanrice
nathanrice / modular-stylesheets.php
Last active April 11, 2020 14:36
A simple proof-of-concept for modularizing the CSS for each block, and linking it "just in time".
<?php
// this snippet requires PHP 5.3+
add_action( 'wp_enqueue_scripts', function() {
wp_register_style( 'atomic-blocks/ab-cta', '/path/to/atomic-blocks/css/ab-cta.css', array(), 1.0.0 );
} );
add_filter( 'render_block', function( $block_content, $block ) {
if ( 'atomic-blocks/ab-cta' === $block['blockName'] ) {
ob_start();
wp_print_styles( $block['blockName'] );