Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
/*
Makes WordPress' PressThis use vimeo short code instead of <object>/<embed> tags.
Add this to the WordPress theme's function.php file.
Addresses the Vimeo question from StackExchange here:
http://webapps.stackexchange.com/questions/3834/customizing-press-this-quick-posting-for-wordpress
*/
add_action('admin_print_footer_scripts','greatjakes_admin_print_footer_scripts');
function greatjakes_admin_print_footer_scripts() {
if ($_SERVER['PHP_SELF']=='/wp-admin/press-this.php') {
$script=<<<SCRIPT
<?php
/*
wp-all-posts-for-any-term-in-a-taxonomy.php
This is an example showing a hook used to add the ability to use "any" as a term to match all terms for a taxonomy.
It will run as a standalone file in the root of a WordPress 3.0 install with a URL that looks like:
http://example.com/wp-all-posts-for-any-term-in-a-taxonomy.php
It was written to address this question:
@mikeschinkel
mikeschinkel / gist:493178
Created July 28, 2010 01:57
Sample SQL file to return menu items for a post in WordPress 3.0
<?php
include "wp-load.php";
$post_id = $_GET['post'];
$menu_id = $_GET['menu'];
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("SELECT t.term_id as menu_id,
t.name AS menu_name,
<?php
include "wp-load.php";
$post_id = $_GET['post'];
$menu_id = $_GET['menu'];
$term = get_term($menu_id, 'nav_menu');
$menu_items = new WP_Query(
<?php
/*
* Example code showing how to hook WordPress 3.0 to allow for querying multiple taxonomies
* Uses two (2) approaches:
*
* 1. A "tax_terms" URL parameter: WP_Query('tax_terms=type:dining,city:mb,package:discounts')
* 2. Taxonomies as URL parameters: WP_Query('type=dining&city=mb&package=discounts')
*
* To try this example:
*
<?php
/*
* Example code showing how to hook WordPress 3.0 to allow for querying multiple meta_keys.
* It uses this approach for setting criteria where the keys get array indexed (the following
* query will query a hypothetical list of products for those colored Red and sized Large
* and it will sort them in price order:
*
* WP_Query('post_type=product&meta[color]=Red&meta[size]=Large&meta_key=price&orderby=meta_value_num')
*
* To try this example:
/*
Answer to: http://wpquestions.com/question/show/id/694
By: Mike Schinkel
Handles URL Rewriting in WordPress 3.0 like this:
fastigheter-spanien/X -> property/X&lang=sv
fastigheter-usa/X -> property/X&lang=sv
<?php
/*
Handles URL Rewriting in WordPress 3.0 like this:
fastigheter-spanien/X -> property/X&lang=sv
fastigheter-usa/X -> property/X&lang=sv
properties-spain/X -> property/X&lang=en
properties-usa/X -> property/X&lang=en
<?php
/**
* TwentyTen functions and definitions
*
* Sets up the theme and provides some helper functions. Some helper functions
* are used in the theme as custom template tags. Others are attached to action and
* filter hooks in WordPress to change core functionality.
*
<?php
/*
* Example code showing how to hook WordPress to add fields to the taxonomny term edit screen.
*
* This example is meant to show how, not to be a drop in example.
*
* This example was written in response to this question:
*
* http://lists.automattic.com/pipermail/wp-hackers/2010-August/033671.html
*