This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In functions.php: | |
function load_podcast_from_slug($slug) { | |
echo "https://soundcloud.com/graphicdesignerpodcast" . $slug; | |
} | |
In single.php inside the loop: | |
load_podcast_from_slug($post->post_name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calc_years_since($year) { | |
$since = date("Y") - $year; | |
if ($since == 1) { | |
$since .= " year"; | |
} else { | |
$since .= " years"; | |
} | |
echo $since; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Forked from jmlacroix/aws_cf_invalidate.rb | |
# Modified to read s3 creds from the environment and the distribution id from arguments passed in. | |
require 'rubygems' | |
require 'hmac-sha1' | |
require 'net/https' | |
require 'base64' | |
s3_access=ENV['S3_ACCESS'] | |
s3_secret=ENV['S3_SECRET'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Checking in/out: | |
$ git clone [project url] - get a copy of repo in a folder | |
$ git checkout [file] - check out last committed version of a file | |
$ git add --patch [file] - Step through each section of changes in a file with option to stage or not stage | |
$ git remote rm origin - remove origin | |
$ git remote add origin [url] - add origin | |
Working with Branches: | |
$ git branch [foo] - create branch named foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hook into the single_template filter to use a custom template for one particular | |
// post and still have it appear in the regular blog archives, featured posts, etc. | |
// Template should be named 'single-[postID].php. | |
add_filter('single_template', 'widget_custom_post'); | |
function widget_custom_post($template) { | |
global $post; | |
// If it's the desired post, override the standard template with custom. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//finally have a function to check if we're anywhere on the damned blog and only the blog | |
function is_blog() { | |
if ( get_post_type() == 'post' || is_post_type_archive( 'post' ) ) { | |
$blog = is_home() || is_archive() || is_single(); | |
return $blog; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//print page and parent slugs for css classes | |
function page_slug_classes($classes) { | |
global $post; | |
$classes = array(); | |
//get the slug of any parent pages | |
$parent_slug = basename(get_permalink($post->post_parent)); | |
array_push($classes, $parent_slug); | |
//get the slug of the current page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In functions.php: | |
function get_taxonomy() { | |
$taxonomy = wp_get_object_terms( $post->ID, '[taxonomy]', array("fields" => "names") ); | |
$taxonomy = $taxonomy[0]; | |
echo $taxonomy; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Have two taxonomies. Both work in WP admin, and can be displayed with get_the_term_list(). But one won't work with wp_tag_cloud(). | |
Working taxonomy: | |
add_action( 'init', 'create_post_flags' ); | |
function create_post_flags() { | |
$labels = array( | |
'name' => _x( 'Post Flags', 'taxonomy general name' ), | |
'singular_name' => _x( 'Post Flag', 'taxonomy singular name' ), | |
'search_items' => __( 'Search Post Flags' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript">var submitted=false;</script> | |
//This is where thank you page/message is loaded. Replace onload function with jQuery hide/show or page redirect to separate page {window.location='thankyou.html';}. | |
<iframe name="hidden_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted) {$('#formblock').hide(); $('#thankyou').fadeIn('fast');}"></iframe> | |
//replace form key with actual key from Google Docs | |
<form action="https://docs.google.com/a/betterment.com/spreadsheet/formResponse?formkey=dGlUczJTRUNjaHExOGtqZkVCYjVtR3c6MQ&ifq" method="post" target="hidden_iframe" id="commentForm" onsubmit="submitted=true;"> | |
<div id="formblock"> | |
//recreate form fields and validation if needed |
NewerOlder