Skip to content

Instantly share code, notes, and snippets.

View jonschr's full-sized avatar

Jon Schroeder jonschr

View GitHub Profile
@jonschr
jonschr / gist:569876a43c034bd67852
Last active September 17, 2015 18:33
Assigning sidebars when working with both genesis simple sidebars and woocommerce on a genesis theme
/**
* Assign the sidebars
*/
add_action( 'genesis_header','rb_change_genesis_sidebar' );
function rb_change_genesis_sidebar() {
global $post;
if ( get_post_type() == 'post' ) { // Check if we're on a single post for the 'post' post type
remove_action( 'genesis_sidebar', 'genesis_do_sidebar'); // remove the default genesis sidebar
<?php
//* Do not include the opening php tag
//* Unregister the primary sidebar
unregister_sidebar( 'sidebar' );
//* Unregister the secondary sidebar
unregister_sidebar( 'sidebar-alt' );
<?php
//* Don't include the opening php tag
/**
* Add an 'envira' shortcode to all default WordPress galleries
*/
add_shortcode( 'gallery', 'prefix_envira_to_gallery_shortcode' );
function prefix_envira_to_gallery_shortcode( $atts ) {
$atts[ 'envira'] = 'true';
return gallery_shortcode( $atts );
@jonschr
jonschr / 0_reuse_code.js
Created October 18, 2015 23:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jonschr
jonschr / template.php
Last active October 19, 2015 00:01
Remove Genesis title links (for use in template file)
<?php
//* Do not include the opening php tag
//* Remove the link from titles
add_filter( 'genesis_post_title_output', 'prefix_custom_post_title' );
function prefix_custom_post_title( $title ) {
$post_title = get_the_title( get_the_ID() );
$title = '<h2 class="entry-title" itemprop="headline">' . $post_title . '</h2>';
return $title;
@jonschr
jonschr / template.php
Last active October 19, 2015 00:02
Force a specific layout
<?php
//* Do not include the opening php tag
//* Force full-width-content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Force content-sidebar
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
//* Force sidebar-content
@jonschr
jonschr / functions.php
Last active October 19, 2015 00:04
Remove Genesis title links (conditionally, for functions.php)
<?php
//* Do not include the opening php tag
//* Remove the link from titles
add_filter( 'genesis_post_title_output', 'prefix_custom_post_title' );
function prefix_custom_post_title( $title ) {
if ( is_post_type_archive( 'post' ) ) {
$post_title = get_the_title( get_the_ID() );
$title = '<h2 class="entry-title" itemprop="headline">' . $post_title . '</h2>';
}
@jonschr
jonschr / template.php
Last active October 19, 2015 00:13
Display a widget
<?php
//* Don't include the opening php tag
//* Display a widget area
genesis_widget_area( 'your-widget-area', array(
'before' => '<div>', // markup before the widget
'after' => '</div>', // markup after the widget
) );
@jonschr
jonschr / functions.php
Created October 19, 2015 00:15
Display a widget somewhere on a site (this example shows it before the footer)
<?php
//* Don't include the opening php tag
//* Display a widget area before the footer
add_action( 'genesis_before_footer', 'prefix_show_your_widget_area' );
function prefix_show_your_widget_area () {
genesis_widget_area( 'your-widget-area', array(
'before' => '<div>', // markup before the widget
'after' => '</div>', // markup after the widget
) );
@jonschr
jonschr / functions.php
Created October 19, 2015 00:19
Filter the footer text and replace it with some of out own
<?php
//* Don't include the opening php tag
//* Filter the footer credits
add_filter( 'genesis_footer_creds_text', 'prefix_footer_creds_text' );
function prefix_footer_creds_text( $args ) {
$args = '[footer_copyright] ' . get_bloginfo( 'name' ) . '<br/>Website handcrafted with love by Your Name';
return $args;
}