Skip to content

Instantly share code, notes, and snippets.

@ramseyp
ramseyp / page_template_column.php
Created December 11, 2012 03:04
Add a page template column to WordPress's Pages view.
<?php
/**
*
* Add page template column to page listing. Make the Template column sortable
* http://www.codehooligans.com/2011/07/13/adding-custom-columns-to-wordpress-post-listing/
* http://justintadlock.com/archives/2011/06/27/custom-columns-for-custom-post-types/
*
*/
@ramseyp
ramseyp / fluidimage.js
Created November 21, 2011 02:08
Part of the WP Fluid Images plugin. Replaces pixel-based width & height attributes with style attributes using percentages.
/**
* Name: fluidimage.js
*
* @author Pat Ramsey <pat@slash25.com>
* @copyright Copyright (c) 2011, Pat Ramsey
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @description Part of the WP Fluid Images plugin. Replaces pixel-based width & height attributes with style attributes using percentages.
*
*/
@ramseyp
ramseyp / lastname-firstname-user-sort.php
Created June 28, 2013 15:33
Sorted the return of a Wp_User_Query by both the last name value and the first name value. This way, if multiple users have the same last name, those particular users are then sorted by first name.
<?php
function s25_member_loop() {
$args = array(
'role' => 'member', // the role we're targeting
'exclude' => '1', // exclude admin
'fields' => 'all_with_meta',
'meta_key' => 'last_name', //query on the last_name key
'meta_key' => 'first_name', // also the first_name key
);
$membersquery = new WP_User_Query( $args );
@ramseyp
ramseyp / base-slider.php
Created July 17, 2013 00:17
Basic carousel / slider code using flexslider.
<?php
/**
* Basic slider. Uses flexslider.js, theme options framework, a custom post type and custom meta boxes.
*
* @author Pat Ramsey
* @link http://slash25.com
*/
add_image_size( 'slider', 920, 286, true ); // we want a new image size for the slider background
@ramseyp
ramseyp / wp_is_mobile-search.php
Created August 2, 2012 21:59
Using wp_is_mobile to conditionally load the search form in Twenty Eleven's header.php file
<?php
/**
*
* Wrap get_search_form with wp_is_mobile() to conditionally load the form in the header.
*
*/
if ( !wp_is_mobile() ) {
get_search_form();
}
@ramseyp
ramseyp / wp_is_mobile_1.php
Created August 2, 2012 21:27
wp_is_mobile - barebones usage
<?php
/**
*
* Test for mobile browsers - if wp_is_mobile is true, then do something.
*
*/
if ( wp_is_mobile() ) {
echo "Do Something if it's a mobile device";
}
@ramseyp
ramseyp / inf-form-placeholder.css
Created October 3, 2012 16:06
CSS used to style Infusionsoft form labels as placeholders
/**
* Works with this Gist: https://gist.github.com/3827830
*/
/* Use this to add styles as necessary to override default form label styles */
.infusion-form .infusion-field .label-placeholder { }
.infusion-form .infusion-field,
.infusion-form .infusion-field .inf_group {
position:relative;
@ramseyp
ramseyp / cat_archive_search.php
Created January 10, 2014 02:09
Search within a WordPress category archive ( Genesis )
<?php
/**
*
* first function gets URL of the current page, which is used in the search as the action parameter.
* second function loads a search box above the content of a Genesis category archive.
* the category name ( slug ) is passed through a hidden input as a search query parameter.
*
**/
function current_page_url() {
$pageURL = 'http';
@ramseyp
ramseyp / 0_reuse_code.js
Created December 19, 2013 18:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ramseyp
ramseyp / no_update_plugin.php
Created November 14, 2013 15:27
Simple code useful if you don't want a WordPress plugin to show an update notice.
<?php
/**
* Keep your plugin from updating
* http://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
*/
function s25_plugin_no_update( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
$plugins = unserialize( $r['body']['plugins'] );
unset( $plugins->plugins[ plugin_basename( __FILE__ ) ] );