Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / custom-post-type-comments-genesis.php
Last active August 29, 2015 13:56
Modify comment settings for custom post types in Genesis
<?php
// Change Comments byline
add_filter( 'genesis_post_info', 'jdn_ticket_info_filter' );
function jdn_ticket_info_filter( $post_info ) {
if( get_post_type() == 'ticket' ) {
$post_info = 'Ticket Opened: [post_date] [post_comments zero="Reply" one="1 Reply" more="% Replies"]';
} else {
$post_info = 'Posted [post_date] by [post_author] [post_comments zero="Leave a Comment" one="1 Comment" more="% Comments"]';
}
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
<?php
/**
* Project Quote
*
*/
function be_project_quote() {
global $wp_query, $be_testimonials;
if( !( ( 5 < $wp_query->found_posts && 5 == $wp_query->current_post % 6 ) || ( $wp_query->current_post == ( $wp_query->found_posts - 1 ) && 5 > $wp_query->found_posts ) ) )
@joshuadavidnelson
joshuadavidnelson / author-avatar-in-post-header.php
Last active August 29, 2015 13:56
Show author avatar in entry header of feature post only, not teasers - in Genesis - support for Co-Authors Plus
<?php
/**
* Places the author avatar next to the entry header for feature posts, not teaser posts.
* Includes support for co-authors plus plugin
* Replace the BLOGLOGURL with an actual url to an alternate image
*
* @author Joshua David Nelson, joshuadnelson.com
**/
add_action( 'genesis_entry_header', 'jdn_author_post_avatar', 1 ); // using a priority of 1 to insure it is first, before title
@joshuadavidnelson
joshuadavidnelson / archive-posts-classes.php
Created February 18, 2014 17:27
Modify Post Classes on Archive Page in Genesis for columns
<?php
/**
* Adds classes to your posts for a specific page (say, a custom post type archive for instance)
*
* @author Joshua David Nelson, joshuadnelson.com
**/
// Three Columns
function jdn_code_archive_post_class( $classes ) {
$classes[] = 'one-third teaser'; // classes, these turn the format into three columns
@joshuadavidnelson
joshuadavidnelson / wp-query-arguments.php
Last active August 29, 2015 13:56 — forked from billerickson/gist:3698476
WP Query Arguments
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@joshuadavidnelson
joshuadavidnelson / is-child-parent-or-sibling-page.php
Last active August 29, 2015 13:56
Determine if post type is a child of another or is the parent.
<?php
/**
* Check is post is the child, sibling or the parent.
*
* Modified from http://css-tricks.com/snippets/wordpress/if-page-is-parent-or-child/
**/
function is_branch( $pid ) { // Check if parent or child
global $post;
if( is_page() && is_int( $pid ) && ( $post->post_parent == $pid || is_page( $pid ) ) ) {
@joshuadavidnelson
joshuadavidnelson / correct-wp_editor-method.php
Last active August 29, 2015 14:00
Fixing the wp_editor error in WordPress 3.9
/**
* This is the correct method of using wp_editor()
**/
// Codex usage:
wp_editor( $content, $editor_id, $settings = array() );
// Example of proper use in a widget
wp_editor( 'content', 'content', array( 'textarea_name' => $this->get_field_id( 'content' ), ) );
// Alternate method when get_field_id is not available (options page or other)
@joshuadavidnelson
joshuadavidnelson / modify-metabox-fields.php
Last active August 29, 2015 14:01
Modifying meta box fields in a child theme
<?php
/**
* Registering meta boxes
*
* Based on these metaboxes and a global metabox variable, but can be modified to suit others:
* @link http://www.deluxeblogtips.com/meta-box/docs/define-meta-boxes
*/
// Add new metaboxes - hook into after the metaboxes have been defined, but before they have been registered
add_action( 'admin_init', 'jdn_modify_metabox_fields', 1 );
@joshuadavidnelson
joshuadavidnelson / page-specific-sidebar.php
Last active August 29, 2015 14:01
Page Specific Sidebar in Genesis
<?php
/**
* Override the default sidebar in a Genesis Child Theme with the following code
*
* @author Joshua David Nelson, josh@joshuadnelson.com
*/
add_action( 'genesis_setup', 'child_theme_setup' );
function child_theme_setup() {