Skip to content

Instantly share code, notes, and snippets.

@wycks
wycks / placekitten.php
Created November 29, 2012 17:58 — forked from thefuxia/placekitten.php
WordPress Plugin for kitten placeholders. Defines an action and a shortcode.
<?php
/*
Plugin Name: Placekitten
Description: Shortcode [placekitten w=100 h=300 g=1 alt=kitten] and action.
Version: 1.0
Author: Thomas Scholz
Author URI: http://toscho.de
License: GPL
*/
@wycks
wycks / image-loop.php
Created November 1, 2012 02:25
Image loop fallback that grabs the first image attached to post if there is no featured image.
<?php
$attachments = get_children(
array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' => 'image',
'post_parent' => get_the_ID(),
'post_status' => null,
'post_type' => 'attachment'
@wycks
wycks / htaccess cache and stuff
Last active March 26, 2022 20:48
Boilerplate .htaccess from Paul Irish with WordPress added
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@wycks
wycks / gist:2906513
Created June 10, 2012 16:32 — forked from GaryJones/gist:1517555
Display some widgets from a sidebar in random order
<?php
add_filter( 'sidebars_widgets', 'gmj_shuffle_widgets' );
/**
* Shuffle ranges of widgets within a sidebar.
*
* Hat-tip to {@link http://gmj.to/op} for the original idea.
*
* @uses gmj_do_shuffle_widgets() Does the actual array manipulation.
*
@wycks
wycks / gist:2685422
Created May 13, 2012 05:46
Jquery UI drag and drop counter
$(function() {
$( "#drag-me" ).draggable();
$( "#drop" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
$('#counter').html(function(i, val) {
return val * 1 + 1
@wycks
wycks / gist:2668630
Created May 12, 2012 20:00
Testing image size filter for post editor
<?php
// test images
add_image_size( 'ducks', 350, 350, true );
add_image_size( 'cows', 750, 150, true );
//this function does not work and acts very wacky
function add_image_check(){
global $_wp_additional_image_sizes;
@wycks
wycks / gist:2624062
Created May 6, 2012 19:44
Output wordpress template in footer source code
<?php
// this is handy for debugging live site, out puts page template in footer source code.
add_action('wp_footer', 'show_template');
function show_template() {
global $template;
echo '<!-- the template is:' . $template . '-->';
}
@wycks
wycks / gist:2389259
Created April 15, 2012 01:39
Chrome Developer Inspect theme (build 18.02) - based on IR_Black Theme
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@wycks
wycks / gist:2377383
Created April 13, 2012 14:46
Register Custom Post Type reference - WordPress
<?php
add_action( 'init', 'register_cpt_example' );
function register_cpt_example() {
//// Label parameters for the CPT admin
$labels = array(
'name' => _x( 'Examples', 'example' ),
'singular_name' => _x( 'Example', 'example' ),
@wycks
wycks / gist:2377285
Created April 13, 2012 14:33 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?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(