Skip to content

Instantly share code, notes, and snippets.

View graylaurenm's full-sized avatar

Lauren Gray graylaurenm

View GitHub Profile
@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',
<?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();
<?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
/* 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' ) );
}
}
@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;
}
@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']*/ )
<?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 );
<div class="subscription-type" style="display: none;">
<input type="checkbox" checked="checked" value="1" name="group[6277][1]" id="mce-group[6277]-6277-0">
<label for="mce-group[6277]-6277-0">Daily Posts</label>
</div>
@graylaurenm
graylaurenm / functions.php
Last active September 22, 2016 00:45
Two Ways to Ensure the WordPress “Read More” Button Links to the Top of Your Post http://oncecoupled.com/2016/09/wordpress-read-more-top-of-post/
<?php // Don't paste this opening line!
function remove_more_link_scroll( $link ) {
$link = preg_replace( '|#more-[0-9]+|', '', $link );
return $link;
}
add_filter( 'the_content_more_link', 'remove_more_link_scroll' );
@graylaurenm
graylaurenm / jump-to-recipe.js
Created October 10, 2016 11:40
Jump and Print buttons for Meal Planner Pro
(function($) {
$(function() {
var jumpID = $( '.mpprecipe-container-border' ).attr( 'id' );
var printID = $( '.butn-link.mpp-button' ).attr( 'onclick' );
var printIDEscaped = htmlEscape(printID);
if( jumpID ) {
if( printID ) { // if jump AND print
$( '.content .entry-header' ).append( '<div class="recipe-buttons"><a class="added-button jump" href="#' + jumpID + '">Jump to Recipe <i class="fa fa-book" aria-hidden="true"></i></a><a class="added-button print" title="Print this recipe" onclick="' + printIDEscaped + '">Print Recipe <i class="fa fa-print" aria-hidden="true"></i></a></div>' );
} else { // if JUST jump