Skip to content

Instantly share code, notes, and snippets.

View mattradford's full-sized avatar
👋

Matt Radford mattradford

👋
View GitHub Profile
@mattradford
mattradford / featured_image_bg.php
Last active October 27, 2015 14:11
Featured image as background
@mattradford
mattradford / header_single.php
Created November 6, 2014 08:27
Different header based on single
<?php if (is_singular( 'cpt_opportunities' ) ) :
get_template_part('templates/page', 'header-opportunities');
else :
get_template_part('templates/page', 'header');
endif;
?>
@mattradford
mattradford / gradient_overlay.css
Created November 6, 2014 11:51
bg gradient overlay
// http://codepen.io/alexcarpenter/pen/LveDx
html, body {
width: 100%;
height: 100%;
}
.bg-img {
width: 100%;
height: 100%;
@mattradford
mattradford / featured_image_notification.php
Created November 6, 2014 12:00
Featured image notification
@mattradford
mattradford / show_tax_terms.php
Created November 6, 2014 14:26
Display all terms for a given taxonomy
<?php
$tax = 'place_of_delivery';
// Show all taxonomy terms
$tax_terms = wp_get_object_terms( $post->ID, $tax );
if (!empty( $tax_terms )) :
echo '<ul>';
foreach( $tax_terms as $term ) {
echo '<li><a href="' . get_term_link( $term->slug, $tax ) . '">' . $term->name . '</a></li>';
}
@mattradford
mattradford / if_get_field.php
Created November 6, 2014 14:58
ACF standard if get_field
<?php if(get_field('field')): the_field('field'); endif; ?>
@mattradford
mattradford / fix_non_ssl.php
Created November 17, 2014 22:59
Fix WP non-HTTPS elements
// fix non-https acf elements
function ssl_post_thumbnail_urls($url, $post_id) {
//Skip file attachments
if(!wp_attachment_is_image($post_id)) {
return $url;
}
//Correct protocol for https connections
list($protocol, $uri) = explode('://', $url, 2);
@mattradford
mattradford / acf_current_user_photo.php
Created November 18, 2014 16:15
ACF current user pho
<?php
global $current_user;
$userID = $current_user->ID;
$imageArray = get_field('your_picture', 'user_' . $userID);
$imageThumbURL = $imageArray['sizes']['thumbnail'];
?>
<img src="<?php echo $imageThumbURL;?>">
@mattradford
mattradford / tax_on_dash.php
Created November 24, 2014 15:21
Add custom taxonomies to custom post type dashboard
add_filter( 'manage_taxonomies_for_cpt_opportunities_columns', 'cpt_opportunities_columns' );
function cpt_opportunities_columns( $taxonomies ) {
$taxonomies[] = 'area_of_study';
$taxonomies[] = 'area_of_interest';
return $taxonomies;
}
@mattradford
mattradford / damn_you_ie.php
Created December 2, 2014 15:25
IE8 conditionals
// Conditionally enqueue IE stylesheets
// http://wpbeaches.com/register-enqueue-internet-explorer-css-style-sheets-wordpress/
function ie_style_sheets () {
wp_register_style( 'ie8', get_stylesheet_directory_uri() . '/css/ie8.css' );
$GLOBALS['wp_styles']->add_data( 'ie8', 'conditional', 'lte IE 8' );
wp_register_style( 'ie7', get_stylesheet_directory_uri() . '/css/ie7.css' );
$GLOBALS['wp_styles']->add_data( 'ie7', 'conditional', 'lte IE 7' );
wp_enqueue_style( 'ie8' );