Skip to content

Instantly share code, notes, and snippets.

View jonschr's full-sized avatar

Jon Schroeder jonschr

View GitHub Profile
@jonschr
jonschr / archive-faq.php
Last active January 28, 2018 10:22
An example custom loop page (uses the standard query, but does whatever it wants inside the loop)
<?php
/**
* NOTE: We force the full-width content in the functions.php file already; no need to do that here as well.
*/
/**
* Remove the standard loop
*/
remove_action( 'genesis_loop', 'genesis_do_loop' );
@jonschr
jonschr / gist:6bc52166db037e880772
Last active April 5, 2023 05:09
Conditional logic with select2 (addon for the Beautiful taxonomy filters plugin)
jQuery(document).ready(function($) {
/**
* If the value is preselected (runs when the the doc is ready)
*/
// get the starting value of the field; empty means no selection is made and conditional fields should hide by default
var startingval = $('select#select-job-industry').val();
if ( startingval == '' ) {
@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
//* 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 );
<?php
//* Do not include the opening php tag
//* Unregister the primary sidebar
unregister_sidebar( 'sidebar' );
//* Unregister the secondary sidebar
unregister_sidebar( 'sidebar-alt' );
@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 / 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 / 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 / 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: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
) );