Skip to content

Instantly share code, notes, and snippets.

@robincornett
robincornett / custom-order.php
Created March 1, 2014 22:43
Order by custom field
<?php
add_action( 'pre_get_posts', 'rgc_custom_order', 9999 );
function rgc_custom_order( $query ) {
if ( $query->is_main_query() && is_post_type_archive( 'your-cpt' ) && !is_admin() ) {
$query->set( 'meta_key', 'custom_field' );
$query->set( 'meta_value', date( 'm/d/Y' ) );
$query->set( 'meta_compare', '>=' );
$query->set( 'orderby', 'meta_value' );
$query->set( 'order', 'DESC' );
@robincornett
robincornett / isotope_init.js
Created March 9, 2014 17:41
modified isotope initialization script. derived from Sridhar Katakam's init at https://gist.github.com/srikat/9406477#file-isotope_init-js
/*
* derived from Sridhar Katakam's init at https://gist.github.com/srikat/9406477#file-isotope_init-js
* tutorial at http://sridharkatakam.com/filterable-portfolio-centric-pro/
*/
//Isotope
jQuery(function($){
$(window).load(function() {
$.Isotope.prototype._masonryResizeChanged = function() {
return true;
<?php
/**
* Portfolio Archive
*/
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'post_class', 'be_portfolio_post_class' );
function be_portfolio_post_class( $classes ) {
if ( is_main_query() ) { // conditional added so that column classes don't apply to widget
@robincornett
robincornett / simple-staff-order.php
Created May 24, 2014 15:48
Example function of how to set the order of posts for an archive or taxonomy--specifically for a custom post type, but can be used anywhere posts are listed, such as a specific category/taxonomy.
<?php
/*
* This function is part of Simple Staff for Genesis. Extracted for educational purposes. Could be used also
* in a theme's functions.php file, if you're not working with a plugin. Do not include the opening tag.
*/
add_action( 'pre_get_posts', 'simple_staff_order', 9999 );
function simple_staff_order( $query ) {
if ( $query->is_main_query() && ( is_post_type_archive( 'staff' ) || is_tax( 'department' ) ) ) {
@robincornett
robincornett / functions.php
Created June 25, 2014 18:07
Conditionally replace primary navigation menu for front page. (question here: http://www.studiopress.com/forums/topic/genesis-menus/)
<?php
// Add this to your functions file, but do not include the lines above this!
add_action( 'template_redirect', 'remove_nav_exclude_blog_page' );
/**
* @author Brad Dalton - WP Sites
* @learn more http://wpsites.net/web-design/conditionally-remove-your-primary-secondary-nav-menu/
*/
function remove_nav_exclude_blog_page() {
@robincornett
robincornett / front-page.php
Last active August 29, 2015 14:04
Alternative front page template for the Genesis Framework--to allow a static home page with optional widget areas.
<?php
/**
* Front Page template for Robin Works theme. Optionally adds widget areas to be used in addition
* to a static home page.
*
*
* @author Robin Cornett
* @license GPL-2.0+
* @link http://robincornett.com/
@robincornett
robincornett / functions.php
Created July 24, 2014 14:39
modify Genesis copyright info in site footer
<?php
// Add the following to your child theme functions.php file. Do not include the opening tag!
//* Change footer text
add_filter( 'genesis_footer_creds_text', 'robin_works_footer_creds_filter' );
function robin_works_footer_creds_filter( $creds ) {
$creds = '[footer_copyright] <a href="' . home_url() . '">' . get_bloginfo( 'name' ) . '</a> | Design by <a href="http://robincornett.com">Robin Cornett</a>';
return $creds;
}
@robincornett
robincornett / functions.php
Last active August 29, 2015 14:05
add featured image to feed (for feeds using excerpts instead of full content). Uses the thumbnail sized image, aligned left, with a margin for the email.
<?php
// you can add this to your theme's functions.php file. do not include the opening tag.
add_filter( 'the_excerpt_rss', 'rgc_add_featured_image_to_feed_excerpt', 1000, 1 );
function rgc_add_featured_image_to_feed_excerpt( $content ) {
if ( has_post_thumbnail( get_the_ID() ) ) {
$content = get_the_post_thumbnail( get_the_ID(), 'thumbnail', array( 'align' => 'left', 'style' => 'margin-right:20px;' ) ) . $content;
}
@robincornett
robincornett / functions.php
Created September 25, 2014 17:23
apple touch, extra favicon
<?php
//* Apple Touch Icon
add_filter( 'wp_head', 'rgc_apple_touch_icon' );
function rgc_apple_touch_icon() {
echo '<link rel="apple-touch-icon" href="' . get_stylesheet_directory_uri() . '/images/apple-touch-icon.png">';
}
@robincornett
robincornett / archive-product.php
Created November 10, 2014 15:53
Simple Shop set up with an intelligent grid
<?php
/**
* Archive page for products (custom post type).
*
*/
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );