Skip to content

Instantly share code, notes, and snippets.

View cdils's full-sized avatar

Carrie Dils cdils

View GitHub Profile
@cdils
cdils / after-entry-widget.php
Last active December 28, 2015 05:18
Drop this in functions.php in any Genesis HTML5-enabled theme to add a widget area after single posts.
<?php // Get rid of this tag
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'after-entry',
'name' => __( 'After Entry', 'theme-prefix' ),
'description' => __( 'This is the after entry section.', 'theme-prefix' ),
) );
//* Hooks after-entry widget area to single posts
@cdils
cdils / editor-style.php
Last active March 27, 2020 05:49
Apply theme's stylesheet to the visual editor.
add_action( 'init', 'cd_add_editor_styles' );
/**
* Apply theme's stylesheet to the visual editor.
*
* @uses add_editor_style() Links a stylesheet to visual editor
* @uses get_stylesheet_uri() Returns URI of theme stylesheet
*/
function cd_add_editor_styles() {
add_editor_style( get_stylesheet_uri() );
@cdils
cdils / genesis-grid-loop.php
Created October 21, 2013 22:48
To use grid loop on a page instead of the standard Genesis loop.
//* Remove entry meta in entry footer and Genesis loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
//* Add Genesis grid loop
add_action( 'genesis_loop', 'my_grid_loop_helper' );
//* Genesis grid loop
function my_grid_loop_helper() {
if ( function_exists( 'genesis_grid_loop' ) ) {
@cdils
cdils / taxonomy-term-as-class.php
Last active December 24, 2015 21:59
Use within the loop (on a single post) to grab all taxonomy terms for post. Take each term and add it as a custom body class.
//* Add taxonomy term as body class to the header
add_filter( 'body_class', 'cd_body_class' );
function cd_body_class( $classes ) {
// Create array of terms within taxonomy named "group"
$terms = get_the_terms( $post->ID , 'group' );
// If there are no terms, bail
if ( $terms == null )
$return;
@cdils
cdils / proper-table-markup.html
Last active December 9, 2018 00:41
Bootstrap table styles (See tutorial to add Bootstrap table styles to your theme -> https://carriedils.com/add-bootstrap-table-styles-theme/)
<!--
<thead> Groups the header content in a table
<th> Defines a header cell in a table
<tbody> Groups the body content in a table
<td> Defines a cell in a table
-->
<table>
<thead>
<?php
add_filter( 'genesis_attr_content', 'yoast_schema_empty', 20 );
add_filter( 'genesis_attr_entry', 'yoast_schema_event', 20 );
add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 );
add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 );
add_filter( 'genesis_post_title_output', 'yoast_title_link_schema', 20 );
/**
* We'll use the post info output to add more meta data about the event.
@cdils
cdils / cpt-taxonomy.php
Created September 27, 2013 21:33
Register Portfolio post type and a related taxonomy called Groups
<?php
/**
* This file contains code related to Custom Post Types & Taxonomies
/**
* Create portfolio custom post type
*
*/
function create_post_types() {
@cdils
cdils / conditional.php
Created September 15, 2013 12:50
Conditional Examples.
add_action( 'get_header', 'cd_change_genesis_sidebar' );
function cd_change_genesis_sidebar() {
if ( 'Author Display Name' == get_the_author() ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'cd_do_sidebar' );
}
@cdils
cdils / functions.php
Last active February 6, 2024 09:51
Add utility bar widget areas above header.
<?php // Remove this line
/** Register Utility Bar Widget Areas. */
genesis_register_sidebar( array(
'id' => 'utility-bar-left',
'name' => __( 'Utility Bar Left', 'theme-prefix' ),
'description' => __( 'This is the left utility bar above the header.', 'theme-prefix' ),
) );
genesis_register_sidebar( array(