This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$meta_args = array( array( 'key' => 'featured', 'value' => '"yes"', 'compare' => 'LIKE' ) ); | |
$args = array( 'post_type' => 'event', 'post_status' => 'future', 'order' => 'ASC', 'orderby' => 'date', 'meta_query' => $meta_args ); | |
$featured = new WP_Query( $args ); | |
?> | |
<?php if ( $featured->have_posts() ): ?> | |
<?php while ( $featured->have_posts() ): $featured->the_post(); ?> | |
<!-- loop here --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() { |