Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / custom-post-type-comments-genesis.php
Last active Aug 29, 2015
Modify comment settings for custom post types in Genesis
View custom-post-type-comments-genesis.php
<?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"]';
}
View gist:8964210
<?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(
View archive-projects.php
<?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 Aug 29, 2015
Show author avatar in entry header of feature post only, not teasers - in Genesis - support for Co-Authors Plus
View author-avatar-in-post-header.php
<?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 Feb 18, 2014
Modify Post Classes on Archive Page in Genesis for columns
View archive-posts-classes.php
<?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
View wp-query-arguments.php
<?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 Aug 29, 2015
Determine if post type is a child of another or is the parent.
View is-child-parent-or-sibling-page.php
<?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 Aug 29, 2015
Fixing the wp_editor error in WordPress 3.9
View correct-wp_editor-method.php
/**
* 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 Aug 29, 2015
Modifying meta box fields in a child theme
View modify-metabox-fields.php
<?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 Aug 29, 2015
Page Specific Sidebar in Genesis
View page-specific-sidebar.php
<?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() {
You can’t perform that action at this time.