Skip to content

Instantly share code, notes, and snippets.

View graylaurenm's full-sized avatar

Lauren Gray graylaurenm

View GitHub Profile
<?php
/**
* Template Name: Category Index
* Created By: Lauren Gray Designs
* URL: http://oncecoupled.com
*/
// Remove the loop and replace it with our own
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'LGD_add_archive', 9 );
@graylaurenm
graylaurenm / functions.php
Last active August 29, 2015 14:05
Add default fallback image in Genesis
<?php
/**
* Set default fallback image
* Modified from: https://gist.github.com/GaryJones/7070243
* See: genesis\lib\functions\image.php
*/
add_filter( 'genesis_get_image_default_args', 'prefix_stop_auto_featured_image' );
function prefix_stop_auto_featured_image( $args ) {
if ( ! isset( $args['context'] ) /*|| 'archive' !== $args['context']*/ )
@graylaurenm
graylaurenm / functions-1.php
Created August 10, 2014 14:02
Add Images to RSS
/*
* Use to insert images into your RSS content. Good for use with Feedburner.
*/
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'display: block; max-width: 100%; height: auto; margin: 10px 0;' ) ) . '' . $content;
}
<?php
/* add link at beginning of excerpt */
add_filter( 'genesis_entry_content' , 'lgd_clickable_open', 1 );
function lgd_clickable_open() {
if (is_home() || is_front_page() || is_archive() ) {
printf( '<a href="%s" alt="%s">', get_permalink(), the_title_attribute( 'echo=0' ) );
}
}
<?php
//* Enqueue child theme JavaScript.
add_action( 'wp_enqueue_scripts', 'lgd_enqueue_js' );
//* Load additional javascript.
function lgd_enqueue_js() {
wp_enqueue_script( 'social-by-post', get_stylesheet_directory_uri().'/js/social-by-post.js' , '', '', true );
}
<?php # EXAMPLE TO REGISTER AND POSITION ANY NEW WIDGET AREAS
/**
* Created By: Lauren Gray Designs
* URL: http://oncecoupled.com
*/
//* POSTS Register new widget area
lgd_register_sidebars();
@graylaurenm
graylaurenm / page_category_index-2.php
Last active August 29, 2015 14:02
List Posts By Category: Custom page template to grab all categories and create an un-ordered list of posts within each. Page template create for Genesis, but could be adapted to any WordPress theme. http://oncecoupled.com/2014/06/13/page-template-list-posts-by-category/
<?php
/**
* Template Name: Category Index
* Created By: Lauren Gray Designs
* URL: http://oncecoupled.com
*/
/* Exclude categories: */
$args = array(
'type' => 'post',