Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@joshuadavidnelson
joshuadavidnelson / is_custom_post_type.php
Last active January 2, 2016 10:39
Checks if the current post is a custom post type, returns boolean
<?php
/**
* Checks if current post is a custom post type, returns boolean
*
* @author Joshua David Nelson
* @link http://joshuadnelson.com/code/is_custom_post_type/
*/
if ( !function_exists( 'is_custom_post_type' ) ) {
function is_custom_post_type() {
@joshuadavidnelson
joshuadavidnelson / cpt_has_archive.php
Last active December 11, 2021 10:54
Check if a custom post type supports archives
<?php
/**
* Check if post type supports an archive
*
* @param string $post_type post type name
* @uses get_post_type
* @global object $post
* @returns boolean
* @author Joshua David Nelson
*/
@joshuadavidnelson
joshuadavidnelson / remove-in-post-layouts.php
Created January 10, 2014 17:21
Remove in-post layouts for a specific post type
/**
* Remove in-post layout support for 'product' post type
*
* @link http://www.studiograsshopper.ch/web-development/how-to-use-genesis-connect-for-woocommerce/#gcw-remove-layouts
*/
add_action( 'init', 'child_remove_post_type_support' );
function child_remove_post_type_support() {
remove_post_type_support( 'product', 'genesis-layouts' );
}
@joshuadavidnelson
joshuadavidnelson / remove-metaboxes.php
Created January 10, 2014 17:32
Remove post metaboxes per specific post
<?php
/**
* Remove Post Metaboxes on a specific post
*
* @link http://wordpress.stackexchange.com/questions/74280/remove-metabox-from-specific-page-template-in-admin#74283
*/
add_action( 'admin_menu', 'jdn_remove_post_meta_boxes' );
function jdn_remove_post_meta_boxes()
@joshuadavidnelson
joshuadavidnelson / exclude-scripts.php
Last active January 4, 2016 00:39
Exclude scripts from Scripts to Footer plugin, place them back into the wp_head
<?php
/**
* Exclude scripts from Scripts to Footer plugin
* http://wordpress.org/plugins/scripts-to-footerphp/
*
* In this example, we will use jQuery (hosted on Google's servers even)
*/
add_action( 'wp_print_styles', 'jdn_deregister_scripts', 100 );
add_action( 'wp_head', 'jdn_head_scripts' );
@joshuadavidnelson
joshuadavidnelson / remove-bio-box.php
Created February 5, 2014 23:54
Remove Biographical Box from User Profile (or other element) for specific users
<?php
// Set which users to hide box
add_action( 'admin_init', 'jdn_remove_bio_box' );
function jdn_remove_bio_box() {
if( !current_user_can( 'edit_published_posts' ) ) {
add_action( 'personal_options', array ( 'JDN_Hide_Profile_Bio_Box', 'start' ) );
}
}
@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"]';
}
@joshuadavidnelson
joshuadavidnelson / force-genesis-admin-settings.php
Created February 7, 2014 20:03
Force Genesis admin settings for admin, display genesis admin menu
<?php
/**
* Force Genesis Admin Settings for all administrators
**/
// Force Genesis on Admin
add_action( 'admin_init', 'jdn_force_genesis_admin' );
function jdn_force_genesis_admin() {
if( current_user_can( 'create_users' ) ) { // If this is an Admin
$user_id = get_current_user_id();
<?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 ) ) )