Skip to content

Instantly share code, notes, and snippets.

View mattradford's full-sized avatar
👋

Matt Radford mattradford

👋
View GitHub Profile
@mattradford
mattradford / struckthrough.less
Created July 21, 2015 12:03
Heading with strikethrough line. Needs a heading with an inner span
.struckthrough {
padding: 36px 10px;
h2 {
text-align: center;
position: relative;
z-index:1;
font-size: 20px;
text-transform: uppercase;
margin: 0;
@mattradford
mattradford / jquery_div_toggle.js
Created June 8, 2015 09:47
jQuery toggle multiple divs independently with text change
$(".event-more-control").click(function(e) {
e.preventDefault(); // prevent default click event
$(this).toggleClass('active');
$(this).parentsUntil('event-index-details').children(".event-excerpt").slideToggle(500);
$(this).children(".link-text").text(function(i, oldText) {
return oldText === 'More' ? 'Less' : 'More';
});
});
@mattradford
mattradford / new_gist_file_0
Created May 26, 2015 15:21
Add Custom taxonomy to body class
// Adapted from http://krogsgard.com/2012/wordpress-body-class-post-meta/
add_filter('body_class','tend_custom_tax_body_class');
function tend_custom_tax_body_class( $classes ) {
global $wp_query;
$postid = $wp_query->post->ID;
if ( is_single() ) {
$post_styles = 'post_style';
@mattradford
mattradford / flexbox.less
Last active August 29, 2015 14:21 — forked from jayj/flexbox.less
// --------------------------------------------------
// Flexbox LESS mixins
// The spec: http://www.w3.org/TR/css3-flexbox
// --------------------------------------------------
// Flexbox display
// flex or inline-flex
.flex-display(@display: flex) {
display: ~"-webkit-@{display}";
display: ~"-moz-@{display}";
@mattradford
mattradford / parent_template_switch.php
Created May 14, 2015 16:09
Switch template based on page parent or grandparent. Requires the page parent template is set.
// Switch template based on page parent or grandparent. Requires the page parent template is set.
add_action('template_include', 'auto_child_template');
function auto_child_template( $template = '' ) {
global $post;
if ( ! is_page() ) {
return $template;
}
else {
@mattradford
mattradford / woo_product_dropdown.php
Created May 11, 2015 14:37
woo Product categories in a dropdown (select)
<?php
$terms = get_terms( 'product_cat' );
echo '<select class="product-category-list">';
foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
if ( is_wp_error( $term_link ) ) {
continue;
} ?>
@mattradford
mattradford / page_navigation.php
Created April 8, 2015 16:04
page navigation, from bones
<?php
// Numeric Page Navi (built into the theme by default)
function bones_page_navi() {
global $wp_query;
$bignum = 999999999;
if ( $wp_query->max_num_pages <= 1 )
return;
echo '<div class="pagination">';
@mattradford
mattradford / firstpost_post_class.php
Last active April 14, 2016 11:35
Change post class if first post
<?php
if ($wp_query->current_post == 0 && !is_paged()) :
$first = ( $wp_query->current_post == 0 && !is_paged() ) ? 'firstpost' : ''; post_class($first);
else :
post_class();
endif;
?>
@mattradford
mattradford / opening_times.php
Created December 18, 2014 14:02
Opening times custom fields
if(get_field('override_opening_time', 'options')) :
echo '<span>' . get_field('override_message', 'options') . '</span>';
else :
$time = current_time('timestamp');
$day = date('N', $time);
if($day==1) :
$today = get_field('monday', 'options');
elseif($day==2) :