Skip to content

Instantly share code, notes, and snippets.


David Cochran davidcochran

View GitHub Profile
View gist:1a3b5dfc0ec750a066ee
$myExcerpt = get_the_excerpt();
$tags = array("<p>", "</p>");
$myExcerpt = str_replace($tags, "", $myExcerpt);
echo $myExcerpt;
<!-- -->
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: -->
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" />
by Alexey Ten
Exploits the way browsers render the image tag. Widely supported, including all major browsers.
View Create-list-of-tag-names-from-classes.markdown
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; //
vertical-align: top; // Safari defaults to vertical-align center
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 / 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) {
var div = $(this).attr('href');
$("html, body").animate({
scrollTop: $(div).position().top
}, "slow", "swing");
davidcochran / wp-loop-exclude-post-query
Created Oct 29, 2013
Exclude a certain post from the loop.
View wp-loop-exclude-post-query
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 |

davidcochran /
Last active Dec 26, 2015
Some of my favorite Terminal aliases

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.