This file contains 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
function render_acf_image( $img_obj, $fallback = '900x900', $prefix = '' ) { | |
if( !empty($img_obj) ): | |
$img_sizes = $img_obj['sizes']; | |
$breakpoints = array( | |
'xs' => '0px', | |
'sm' => '576px', | |
'md' => '768px', | |
'lg' => '992px', |
This file contains 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 ACF File | |
* | |
* @param string $key – the ACF field key | |
* @param string $post_id – the ID of the post (if empty, will use $post->ID) | |
* @return string The image URL | |
**/ | |
function get_acf_file( $key = 'file', $post_id = '' ) { | |
if($post_id == ''): | |
global $post; |
This file contains 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 ACF Image | |
* | |
* @param string $size – the dimension of the image (using add_image_size() function) | |
* @param string $key – the ACF field key | |
* @param string $post_id – the ID of the post (if empty, will use $post->ID) | |
* @return string The image URL | |
**/ | |
function get_acf_image( $size = 'full', $key = 'image', $post_id = '' ) { |
This file contains 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
// Force Page CPT to have excerpt (all users) | |
// ------------------------------------------------------------- | |
if ( is_admin() ) : | |
function force_excerpt_box() { | |
// get all post types (excluding posts) | |
$post_types = array('page'); | |
// get all users | |
$all_users = get_users( ); |
This file contains 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
// Format date to remove 00 with on-hour times | |
// ------------------------------------------------------------- | |
function mixd_format_time($time, $meridiem = false){ | |
$full_time = intval($time); | |
$time = str_split($time, 2); | |
$hour = date('g', mktime($time[0], 0, 0, 1, 1, 2000)); | |
$minute = $time[1]; | |
$day_split = ''; | |
This file contains 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 | |
// Make CPT use taxonomy permalink | |
//-------------------------------------- | |
add_filter('post_type_link', '<CPT>_permalink_filter_function', 1, 3); | |
function <CPT>_permalink_filter_function( $post_link, $id = 0, $leavename = FALSE ) { | |
if ( strpos('%<TAXONOMY>%', $post_link) === 'FALSE' ) { | |
return $post_link; | |
} | |
$post = get_post($id); | |
if ( !is_object($post) || $post->post_type != '<CPT>' ) { |
This file contains 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
// Remove columns from Page section | |
// ------------------------------------------------------------- | |
function my_pages_columns( $defaults ) { | |
unset( $defaults['comments'] ); | |
unset( $defaults['author'] ); | |
unset( $defaults['tags'] ); | |
unset( $defaults['date'] ); | |
// WordPress SEO | |
unset( $defaults['wpseo-title'] ); |
This file contains 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
// Set Meetup to alphabetical order and no pagination (in admin) | |
// ------------------------------------------------------------- | |
function set_venue_admin_order($wp_query) { | |
if (is_admin()) { | |
$post_type = $wp_query->query['post_type']; | |
if ( $post_type == 'venue') { | |
$wp_query->set('orderby', 'title'); | |
$wp_query->set('order', 'ASC'); |
This file contains 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
// Force CPTs to have no pagination | |
// ------------------------------------------------------------- | |
if ( is_admin() ) : | |
function force_no_admin_pagination() { | |
// get all post types (excluding posts) | |
$post_types = get_post_types(); | |
unset($post_types['post']); | |
// get all users |
This file contains 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
// Add Hospital filter to CPTs (in admin) | |
// ------------------------------------------------------------- | |
function restrict_people_by_hospital() { | |
global $typenow; | |
$taxonomy = 'hospital'; | |
if ($typenow == 'consultant') { | |
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; | |
$info_taxonomy = get_taxonomy($taxonomy); | |
wp_dropdown_categories(array( | |
'show_option_all' => __("All {$info_taxonomy->label}s"), |
NewerOlder