Skip to content

Instantly share code, notes, and snippets.

@milesstewart88
milesstewart88 / WordPress - Custom field values in Custom Columns
Created July 28, 2013 16:31
Place the custom field values in the custom columns
/*
* Custom fields in custom admin columns
*/
add_action( 'manage_orders_posts_custom_column', 'my_manage_orders_columns', 10, 2 );
function my_manage_orders_columns( $column, $post_id ) {
global $post;
switch( $column ) {
@milesstewart88
milesstewart88 / WordPress - Custom CPT Columns
Created July 28, 2013 01:49
Custom CPT Columns // manage_edit-{post_name}_columns. To add the custom fields to the admin columns
<?php
/*
* Orders - Custom Columns
*/
add_filter( 'manage_edit-orders_columns', 'my_edit_orders_columns' ) ;
function my_edit_orders_columns( $columns ) {
$columns = array(
@milesstewart88
milesstewart88 / PHP - Function - Explode Multiple Params
Created July 12, 2013 17:06
PHP - Function - Explode Multiple Params
<?php
function explodeMeTwice ($param) {
$id_pieces = explode("&", $param);
$new_piece = array();
foreach ($id_pieces as $piece) {
$the_piece = explode("=", $piece);
$new_piece[$the_piece[0]] = $the_piece[1];
@milesstewart88
milesstewart88 / MySQL - Having Clause
Last active December 18, 2015 22:59
Using the HAVING keyword
/*
* When creating alias' and temp tables
* can't use where so use the
* HAVING keyword
*/
SELECT
CONCAT(bill_first_name, ' ', bill_last_name) AS full_name,
COUNT(CONCAT(bill_first_name, ' ', bill_last_name)) AS amount,
MAX(ordered_on) as date, email