Extract Query String from Form Submitted URL

$url = "http://www.youtube.com/watch?v=P22G8YHveEg&feature=feedrec_grec_index"
// get the query string of the url
$query_string = parse_url($url, PHP_URL_QUERY);
// parse out the query string into pieces
parse_str($query_string, $pieces);
// echo out the "v=" variable from the query string for storage in the DB and later use in a YouTube video plugin for WordPress
echo $pieces['v'];
// echos "P22G8YHveEg"

WordPress Check If Current Category Has Children

function category_has_children() {
global $wpdb;
$term = get_queried_object();
$category_children_check = $wpdb->get_results(" SELECT * FROM wp_term_taxonomy WHERE parent = '$term->term_id' ");
if ($category_children_check) {
return true;
} else {
return false;
}
}

<?php
if (!category_has_children()) {
//use whatever loop or template part here to show the posts at the end of the line
get_template_part('loop', 'index');
} else {
// show your category index page here
}
?>

Load Plugin First

function load_plugin_first(){
$wp_path_to_this_file = preg_replace('/(.*)plugins/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
$this_plugin = plugin_basename(trim($wp_path_to_this_file));
$active_plugins = get_option('active_plugins');
$this_plugin_key = array_search($this_plugin, $active_plugins);
if($this_plugin_key){
array_splice($active_plugins,$this_plugin_key,1);
array_unshift($active_plugins,$this_plugin);
update_option('active_plugins',$active_plugins);
}
}
add_action('activated_plugin','load_plugin_first');

Query by term and custom field

<?php
$query = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->terms.slug = 'tvlt-notes'
AND $wpdb->term_taxonomy.taxonomy = 'tvlt_category'
AND $wpdb->postmeta.meta_key = 'tvlt_sort'
AND $wpdb->postmeta.meta_value <> '9999'
";

$tvlt_posts = $wpdb->get_results($query, OBJECT);
?>

More Mime's

<?php

function add_mime_types($mime_types){
$mime_types['art'] = 'text/plain';
return $mime_types;
}
add_filter('upload_mimes', 'add_mime_types', 1, 1);

?>

Manual Media Library Access

<?php
//Add this to your functions.php to activate thickbox on your admin page
wp_enqueue_style('thickbox');
wp_enqueue_script('thickbox');
?>

<!-- This is the trigger -->
<a href="http://mydomain.com/wp-admin/media-upload.php?post_id=2662&TB_iframe=1" class="thickbox" >Attach Media</a>

<script type="text/javascript">
//This prevents error and thickbox white screen. Add to your scripts file loaded by your plugin.
function send_to_editor(html){ alert('Attachment Added to Post'); tb_remove(); }
</script>

Count posts in taxonomy

<?php

global $wpdb;
$query = "
SELECT COUNT( DISTINCT cat_posts.ID ) AS post_count
FROM wp_term_taxonomy AS cat_term_taxonomy INNER JOIN wp_terms AS cat_terms ON
cat_term_taxonomy.term_id = cat_terms.term_id
INNER JOIN wp_term_relationships AS cat_term_relationships
ON cat_term_taxonomy.term_taxonomy_id = cat_term_relationships.term_taxonomy_id
INNER JOIN wp_posts AS cat_posts
ON cat_term_relationships.object_id = cat_posts.ID
WHERE cat_posts.post_status = 'publish'
AND cat_posts.post_type = 'post'
AND cat_term_taxonomy.taxonomy = 'my_taxonomy'
AND cat_terms.slug IN ('term_slug','term-slug2')
";
return $wpdb->get_var($query);
?>

Post Columns

add_filter( 'manage_posts_columns', 'add_column_name' );

function add_column_name($defaults) {
$defaults['positions'] = __('Positions');
$defaults['facility'] = __('Facility');
unset($defaults['comments']);
unset($defaults['author']);
unset($defaults['tags']);
unset($defaults['date']);
return $defaults;
}

function get_custom_fields($column_name, $id)
{
if( $column_name == 'positions' )
{
$positions = get_post_meta($id, 'mm_positions', true);
echo $positions;
}

if( $column_name == 'facility' )
{
$facility = get_post_meta($id, 'mm_facility', true);
echo $facility;
}

}

add_action('manage_posts_custom_column', 'get_custom_fields', 10, 2);