Skip to content

Instantly share code, notes, and snippets.

@jonschr
jonschr / archive-faq.php
Last active Jan 28, 2018
An example custom loop page (uses the standard query, but does whatever it wants inside the loop)
View archive-faq.php
<?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 Aug 29, 2015
Conditional logic with select2 (addon for the Beautiful taxonomy filters plugin)
View gist:6bc52166db037e880772
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 Sep 17, 2015
Assigning sidebars when working with both genesis simple sidebars and woocommerce on a genesis theme
View gist:569876a43c034bd67852
/**
* 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
View functions.php
<?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 );
View functions.php
<?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 Oct 19, 2015
Force a specific layout
View template.php
<?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 Oct 19, 2015
Remove Genesis title links (for use in template file)
View template.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 ) {
$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 Oct 19, 2015
Remove Genesis title links (conditionally, for functions.php)
View 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 Oct 18, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Oct 19, 2015
Display a widget
View template.php
<?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
) );