Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@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 / display-scripts-to-footer.php
Created February 18, 2014 22:05
Disable Scripts to Footer plugin on specific pages
@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 / author-box.php
Created April 29, 2014 17:45
Author Box Template for WordPress Theme
<?php
/**
* Author Box after Post, Template
*
* @author Joshua David Nelson, [email protected]
**/
function jdn_after_post_author_box() {
if ( is_single() ) { // only displays on single post page, not on blog page
$author = get_the_author(); // Display Name
@joshuadavidnelson
joshuadavidnelson / flush-rewrite.php
Created May 7, 2014 18:50
Flush rewrite rules plugin file from WordPress codex. Handy for theme and plugin development.
<?php
/**
* Flush Rewrite rules when the file containing this is changed, or every 48 hours
*
* @link https://codex.wordpress.org/Function_Reference/flush_rewrite_rules
**/
// do not use on live/production servers
add_action( 'init','maybe_rewrite_rules' );
function maybe_rewrite_rules() {
@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 / add-upload-attachments.php
Last active November 6, 2020 16:58
User Dropdown List and Custom Notification Routing in Gravity Forms. See the walkthrough:
<?php
/**
* Add the file uploads to the emails
*
* @author Joshua David Nelson, [email protected]
*
* @link http://www.gravityhelp.com/documentation/page/Gform_user_notification_attachments
* @link http://www.gravityhelp.com/documentation/page/Gform_notification
**/