Skip to content

Instantly share code, notes, and snippets.

View joshuadavidnelson's full-sized avatar

Joshua Nelson joshuadavidnelson

View GitHub Profile
@jtsternberg
jtsternberg / cmb-toggle-fields.css
Last active May 11, 2017 20:30
hidden-toggle for cmb. Works like the WordPress metabox toggle (but for only a selection of fields)
.advanced-toggle .toggle-label {
cursor: pointer;
display: block;
line-height: 3em;
border-bottom: 1px solid #e9e9e9;
border-left: 1px solid #e9e9e9;
border-right: 1px solid #e9e9e9;
padding-left: .8em;
}
.advanced-toggle .inside .cmb-row {
@thomasgriffin
thomasgriffin / gist:d5fd056b8b3dbae1ecbe
Last active August 29, 2015 14:07
Remove any posts from the featured content slider that do not have images in Soliloquy.
<?php
add_filter( 'soliloquy_fc_slider_data', 'tgm_sol_remove_no_image' );
function tgm_sol_remove_no_image( $data ) {
// Loop through the data and remove any items that don't have images.
foreach ( (array) $data['slider'] as $id => $item ) {
if ( empty( $item['src'] ) ) {
unset( $data['slider'][$id] );
}
}
@pburtchaell
pburtchaell / styles.css
Last active February 25, 2024 12:24
VH and VW units can cause issues on iOS devices. To overcome this, create media queries that target the width, height, and orientation of iOS devices.
/**
* VH and VW units can cause issues on iOS devices: http://caniuse.com/#feat=viewport-units
*
* To overcome this, create media queries that target the width, height, and orientation of iOS devices.
* It isn't optimal, but there is really no other way to solve the problem. In this example, I am fixing
* the height of element `.foo` —which is a full width and height cover image.
*
* iOS Resolution Quick Reference: http://www.iosres.com/
*/
@galengidman
galengidman / search.php
Last active September 26, 2021 16:45
WordPress search form & results for custom post type
<?php
// check to see if there is a post type in the URL
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ) {
// save it for later
$post_type = $_GET['post_type'];
// check to see if a search template exists
if ( locate_template( 'search-' . $post_type . '.php' ) ) {
@webaware
webaware / gravity-forms-fields-above.php
Created May 12, 2014 03:39
Move Gravity Forms field labels from below to above fields in compound fields (e.g. Address, Name)
<?php
/*
Plugin Name: Gravity Forms Fields Above
Plugin URI: https://gist.github.com/webaware/24e1bacb47b76a6aee7f
Description: move field labels from below to above fields in compound fields (e.g. Address, Name)
Version: 1
Author: WebAware
Author URI: http://webaware.com.au/
@link http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields
@brycejacobson
brycejacobson / page.php
Created April 9, 2014 17:35
WordPress Genesis custom post type loop
<?php
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
$args = array(
@danielbachhuber
danielbachhuber / gist:9379135
Created March 5, 2014 23:43
Fix network admin URL to include the "/wp/" base
<?php
/**
* Fix network admin URL to include the "/wp/" base
*
* @see https://core.trac.wordpress.org/ticket/23221
*/
add_filter( 'network_site_url', function( $url, $path, $scheme ){
$urls_to_fix = array(
'/wp-admin/network/',
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@jtsternberg
jtsternberg / README.md
Last active June 8, 2023 16:53
Create a theme options page with CMB2
@hissy
hissy / gist:7352933
Created November 7, 2013 11:07
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,