Skip to content

Instantly share code, notes, and snippets.

Avatar

David Cochran davidcochran

View GitHub Profile
View gist:1a3b5dfc0ec750a066ee
<?php
$myExcerpt = get_the_excerpt();
$tags = array("<p>", "</p>");
$myExcerpt = str_replace($tags, "", $myExcerpt);
echo $myExcerpt;
?>
<!-- https://wordpress.org/support/topic/remove-ltpgt-tag-from-excerpt -->
@davidcochran
davidcochran / gist:3a7c980bec460c8139a2
Created Jun 9, 2015
WP Post Excerpt -- only if an excerpt is entered
View gist:3a7c980bec460c8139a2
<?php if ( !empty( $post->post_excerpt ) ) : // if the excerpt field is not empty
the_excerpt(); // do the excerpt
else : // if the excerpt field is empty
false; // no excerpt
endif; ?>
<!-- see: https://wordpress.org/support/topic/if-the_excerpt-is-blank -->
@davidcochran
davidcochran / gist:a2f804576dbc253700fb
Created Sep 29, 2014
SVG with PNG fallback -- from Alexey Ten and CSS Tricks
View gist:a2f804576dbc253700fb
<svg width="96" height="96">
<image xlink:href="svg.svg" src="svg.png" width="96" height="96" />
</svg>
<!--
by Alexey Ten
http://lynn.ru/examples/svg/en.html
Exploits the way browsers render the image tag. Widely supported, including all major browsers.
View Create-list-of-tag-names-from-classes.markdown
@davidcochran
davidcochran / products-grid.less
Created Jan 1, 2014
Create a grid of product items using display: inline-table
View products-grid.less
.products-grid {
display: table;
}
.product-item {
float: none; // override default grid floating behavior
display: inline-table;
margin-right: -1em; // http://www.tylercipriani.com/2012/08/01/display-inline-block-extra-margin.html
vertical-align: top; // Safari defaults to vertical-align center
}
@davidcochran
davidcochran / clear-sm-bootstrap.less
Created Dec 24, 2013
Create a mixin .clear-sm to configure an element to clear the items above it only within a specified media query.
View clear-sm-bootstrap.less
/*
In a situation such as this markup
where we want columns to organize themselves
into two rows at on smaller screens.
This Bootstrap 3 markup gets us most of the way there.
<div class="col-sm-4 col-md-2">
...
<div class="col-sm-4 col-md-2">
...
<div class="col-sm-4 col-md-2">
@davidcochran
davidcochran / jquery-scrollto-simple.js
Created Dec 23, 2013
Animate scroll to all page anchors within the page
View jquery-scrollto-simple.js
// Animate scroll to all page anchors
$('[href^=#]').click(function (e) {
e.preventDefault();
var div = $(this).attr('href');
$("html, body").animate({
scrollTop: $(div).position().top
}, "slow", "swing");
});
@davidcochran
davidcochran / wp-loop-exclude-post-query
Created Oct 29, 2013
Exclude a certain post from the loop.
View wp-loop-exclude-post-query
From:
http://wordpress.org/support/topic/multiple-loops-if-first-post-in-loop-1-matches-first-post-in-loop-2-skip
Add this after the query:
$check = get_posts('cat=3&numberposts=1');
if ( $check[0]->ID == $post->ID ) continue;
View HTML5-Markup-Template---Basic.markdown

HTML5 Markup Template - Basic

A very basic starter template with fundamental HTML5 markup -- only the basics.

Based on HTML5 Bones | http://html5bones.com

@davidcochran
davidcochran / terminal-aliases.md
Last active Dec 26, 2015
Some of my favorite Terminal aliases
View terminal-aliases.md

Some of the Aliases I use in my .bash_profile for OS X Terminal:

# Open a file in Sublime Text 2
alias subl='open -a Sublime\ Text\ 2'

#Edit Bash Profile in Sublime Text 2
alias bashprof='subl .bash_profile'

# Open a file in desired browser
alias ff='open -a Firefox'
You can’t perform that action at this time.