Skip to content

Instantly share code, notes, and snippets.

@chasereeves
chasereeves / gist:3350644
Created August 14, 2012 16:30
Wordpress similar posts without plugin
<?php
//=========================================================== SIDEBAR == Similar Posts
function similar_posts() {
echo "<li class=\"widget similar_posts\">";
echo "<h3>Similar Posts</h3>";
echo "<ul>";
global $post;
//stores the original post data
$original_post = $post;
@chasereeves
chasereeves / gist:3757911
Created September 20, 2012 19:42
Wordpress WP_Query example
<ul class="none">
<?php $lessons_query = new WP_Query( array('post_type' => 'lesson', 'cat' => 21,'orderby' => date, 'order' => DESC, 'posts_per_page' => 5));
while ( $lessons_query->have_posts() ) : $lessons_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
@chasereeves
chasereeves / gist:3794400
Created September 27, 2012 14:45
Course Objectives Initials Outline/Questions
Course Information
==================
Course Name:
------------
Description:
------------
@chasereeves
chasereeves / gist-shortcode.php
Created October 1, 2012 15:45 — forked from norcross/gist-shortcode-css.css
embed gist shortcode
function gist_shortcode($atts, $content = NULL) {
extract( shortcode_atts( array(
'id' => '',
'title' => ''
), $atts ) );
if (empty ($id) )
return;
@chasereeves
chasereeves / gist:3885925
Created October 13, 2012 19:53
Wordpress Custom Meta Box
//=========================================================== Custom Meta Box - Video
$prefix = 'matterful_optionbox_';
$meta_box = array(
'id' => 'matterful_optionbox',
'title' => 'Ice Brimmin&rsquo; Options',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(

Web Design & Development Contract

Between us COMPANY_NAME and you CUSTOMER_NAME on DATE_DATE.

Summary:

We'll always do our best to fulfill your needs and meet your expectations, but it's important to have things written down so that we both know who should do what, when, and what we'll do if something goes wrong. In this contract you won't find any complicated legal terms or long passages of unreadable text. We have no desire to trick you into signing something that you might later regret. What we do want is what's best for both parties, now and in the future.

jQuery('a[href$="mp3"]').each(function(){
var audioURL = jQuery(this).attr('href');
var audioName = jQuery(this).text();
jQuery(this).before('<br/>');
jQuery(this).after('<br/><audio controls src="'+audioURL+'" type="audio/mpeg" preload="none"></audio><br/>');
});
@chasereeves
chasereeves / gist:7093097
Created October 22, 2013 00:07
wordpress: Get first paragraph (first two if paragraph #1 isn't long enough).
//=========================================================== Grab first paragraph (two if first is not long enough)
function get_first_two_paragraphs(){
global $post;
$str = wpautop( get_the_content() );
$psToGrab = 2; // number of paragraphs to get
$maxFirstParaLength = 200; // character max in first paragraph
$matches = array(); // matching elements will go here
$pattern = '%<p[^>]*>(.*?)</p>%i'; // match what's between all <p> tags
preg_match_all($pattern, $str, $matches); // do the regex match
$outparts = array_slice($matches[1], 0, $psToGrab); // chop off everything after the first 2 elements
@chasereeves
chasereeves / gist:7093132
Created October 22, 2013 00:11
Wordpress shortcode for podcast file.
//=========================================================== PODLISTEN SHORTCODE
add_shortcode('podlisten', 'podlisten_shortcode');
// example: [podlisten src="http://your-site/videos/your-audio.mp3"]
function podlisten_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
"src" => ''
), $atts));
return '
<hr class="big"/>
//=========================================================== PODLISTEN SHORTCODE
add_shortcode('podlisten', 'podlisten_shortcode');
// example: [podlisten src="http://your-site/videos/your-audio.mp3"]
function podlisten_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
"src" => ''
), $atts));
return '
<div class="podlisten">