Skip to content

Instantly share code, notes, and snippets.

@danott
danott / entities.css
Created January 31, 2011 22:07
Use CSS's :after pseudo-selector to insert hexadecimal values of html entities into the document. Less markup. More awesome.
/* Daniel Ott
* entities.css
* 31 January 2011
*
* Adding arrows to thinks makes them more clickable. Right?
* Use CSS's :after pseudo-selector to insert hexadecimal values
* of html entities into the document. Less markup. More awesome.
*/
.add-an-arrow:after {
@hakre
hakre / gist:826061
Created February 14, 2011 15:48
WP_Query_Columns - Columns for the loop. - http://wordpress.stackexchange.com/q/9308/178
<?php
/**
* get_columns_array
*
* Columns for the loop, single function interface (limited)
*
* Copyright (c) 2011 hakre <http://hakre.wordpress.com/>, some rights reserved
*
* USAGE:
@scribu
scribu / gist:856587
Created March 5, 2011 18:34
'product' post type + 'color' taxonomy
<?php
// Register the post type and taxonomy
function init_product_cpt() {
register_post_type( 'product', array(
'public' => true,
'label' => __( 'Products', 'my-plugin' )
) );
register_taxonomy( 'color', 'product', array(
@boyvanamstel
boyvanamstel / gist:1055880
Created June 30, 2011 08:52
Show custom post types on tag, category and archive pages in Wordpress
<?php
/**
* Also show custom post types in tag/category/archive pages
*/
function query_post_type($query) {
if(is_category() || is_tag()) {
$post_type = get_query_var('post_type');
if($post_type) {
$post_type = $post_type;
} else {
@mikejolley
mikejolley / template-print-processing-orders.php
Created November 4, 2011 12:45
WooCommerce - Print Processing orders. A template page snippet to (if you are logged in as admin) output all of your orders with 'processing' status (paid) ready for printing.
<?php
/*
Template Name: Print Processing Orders :)
*/
if (!is_user_logged_in() || !current_user_can('manage_options')) wp_die('This page is private.');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@mikejolley
mikejolley / gist:1425282
Created December 2, 2011 23:12
This snippet lets you edit the icon for the PayPal gateway in WooCommerce.
add_filter('woocommerce_paypal_icon', 'custom_woocommerce_paypal_icon')
function custom_woocommerce_paypal_icon( $url ) {
$url = 'http://yoursite,com/youriconurl.png';
return $url;
}
@mikejolley
mikejolley / gist:1503854
Created December 20, 2011 23:52
Extra Profile Fields - simple code to add extra user meta fields to the back-end, place in functions.php
add_action( 'show_user_profile', 'show_extra_profile_fields', 10 );
add_action( 'edit_user_profile', 'show_extra_profile_fields', 10 );
function show_extra_profile_fields( $user ) { ?>
<h3><?php _e('Extra Profile Information'); ?></h3>
<table class="form-table">
<tr>
@mikejolley
mikejolley / gist:1547491
Created January 1, 2012 14:38
WooCommerce - A filter to add a tracking (or any other field for that matter) to order emails to customers.
/* To use:
1. Add this snippet to your theme's functions.php file
2. Change the meta key names in the snippet
3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg
4. When next updating the status, or during any other event which emails the user, they will see this field in their email
*/
add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys');
function my_custom_order_meta_keys( $keys ) {
$keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails
@mikejolley
mikejolley / gist:1604009
Created January 13, 2012 00:31
WooCommerce - Add a special field to the checkout, order emails and user/order meta
/**
* Add the field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
/**
@mikejolley
mikejolley / gist:1622323
Created January 16, 2012 18:54
WooCommerce - Change default catalog sort order
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');
function custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}