Skip to content

Instantly share code, notes, and snippets.

View timmcdaniels's full-sized avatar

Tim McDaniels timmcdaniels

View GitHub Profile
I hereby certify that I am over the age of eighteen years and understand the nature and scope of the risks and dangers associated with playing the game of soccer. I understand that it is not the function of the United States Soccer Federation (USSF) and its affiliates, or the Virginia Soccer Alliance (VSA) and it's member clubs to guarantee the safety of participants in the game. I further understand that each individual participant bears full responsibility to exercise due care in the performance of this activity for the safety of themself and other participants.
I am aware that my participation or that of my minor children includes a risk of possible exposure to and illness from infectious diseases including but not limited to MRSA, influenza, and COVID-19; and that while particular rules and personal discipline may reduce this risk, the risk of serious illness and death does exist; and I KNOWINGLY AND FREELY ASSUME ALL SUCH RISKS, both known and unknown, EVEN IF ARISING FROM THE NEGLIGENCE OF THE RELEASEE
/**
*Get distinct values of custom field from post type
*
*@return void
*@since 0.1
*/
function get_distinct_from_post_type ( $field, $post_type ) {
global $wpdb;
$sql = "SELECT DISTINCT meta_value FROM $wpdb->postmeta pm, $wpdb->posts p WHERE meta_key = '$field' AND pm.post_id=p.ID AND p.post_type='$post_type' ORDER BY meta_value";
return $wpdb->get_results( $sql, ARRAY_A );
@timmcdaniels
timmcdaniels / populate_acf_select_fields
Last active May 6, 2020 15:30
Populating ACF Select Fields with Post Type Values
// populate acf field (sample_field) with post types (sample_post_type)
function acf_load_sample_field( $field ) {
$field['choices'] = get_post_type_values( 'sample_post_type' );
return $field;
}
add_filter( 'acf/load_field/name=sample_field', 'acf_load_sample_field' );
function get_post_type_values( $post_type ) {
$values = array();
@timmcdaniels
timmcdaniels / get_image_src
Last active May 8, 2017 15:07
WordPress Get Image Source Function
<?php
function get_image_src( $id = 0, $size = '', $default_id = 50 ) {
$src = '';
// get src of attachment id
if ( $id > 0 ) {
list( $src, $width, $height ) = wp_get_attachment_image_src( $id, $size );
}
@timmcdaniels
timmcdaniels / wordpress_asset_enqueuing
Last active December 25, 2015 15:19
WordPress Asset Enqueing
<?php
// hook into WordPress wp_enqueue_scripts action with a high priority
// so our function is the last to run
add_action( 'wp_enqueue_scripts', 'theme_enqueue_assets', 99999 );
// function that enqueues our CSS & JavaScript
function theme_enqueue_assets() {