Skip to content

Instantly share code, notes, and snippets.

@ramseyp
ramseyp / show_testimonials.php
Last active December 17, 2015 09:19
Grab a custom post type of testimonial & output it, along with a custom field for the person's credentials / title
<?php
$testimeta = get_post_custom($testimq->post->ID);
if ( $testimeta['s25_testim_cred'][0] !='' ) { $cred = ', '. $testimeta['s25_testim_cred'][0]; } else { $cred = ''; }
echo '<div class="entry-content">'. wpautop( get_the_content($testimq->post->ID), true ) .'</div>';
echo '<p class="attrib"><em>&ndash; '. get_the_title($testimq->post->ID) . $cred .'</em></p>';
echo '</div>';
}
@ramseyp
ramseyp / full-screen-bg.php
Created May 12, 2013 14:25
function for outputting a full-screen background image based off a custom field of "s25_bg_image"
<?php
function s25_full_bg() {
$pgmeta = get_post_custom();
$pgbg = $pgmeta['s25_bg_image'][0];
if ( !is_null( $pgbg ) ) :
echo '<style type="text/css">body{background-image:none !important;background-color:#000 !important;}</style>';
echo '<div class="lpage_bg" style="position:fixed;left:0;top:0;width:100%;height:100%;z-index:-1;background: #ccc url('. $pgbg .') no-repeat fixed center center;-webkit-background-size: cover;-moz-background-size: cover;-o-background-size: cover;background-size: cover;filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'. $pgbg .'", sizingMethod=\'scale\');-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'. $pgbg .'", sizingMethod=\'scale\')";>&nbsp;</div>';
echo '<!--[if IE 8 ]>
$(function() {
var $sidebar = $("#sidebar"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 20;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
<?php
function namespace_add_custom_types( $query ) {
if( is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array( 'post', 'case_study','solution_sheet','white_paper' );
$query->set( 'post_type', $post_type );
return $query;
@ramseyp
ramseyp / short-titles.php
Created February 28, 2013 18:34
Shorten WordPress titles to a set number of characters
<?php
/**
* [short_title description]
* @param $postid the ID of the $post object
* @param $length How long the title should be
* @return Post / Page title shortened to the number of characters in $length
* Usage: short_title( $postid, 45 );
*/
function short_title( $postid,$length) {
global $post;
@ramseyp
ramseyp / last-word.js
Created February 21, 2013 15:13
Select the last word in an element & wrap it with a span tag
jQuery(document).ready(function($){
$('h2.title').html(function(){
// separate the text by spaces
var text= $(this).text().split(' ');
// drop the last word and store it in a variable
var last = text.pop();
// join the text back and if it has more than 1 word add the span tag
// to the last word
return text.join(" ") + (text.length > 0 ? ' <span class="last">'+last+'</span>' : last);
@ramseyp
ramseyp / genesis-child-webfonts.php
Created January 17, 2013 05:58
Load Google Webfonts into a Genesis Child Theme using the functions.php file
/**
*
* Add Google Webfonts
*/
add_action('wp_head','s25_webfont_load');
function s25_webfont_load() {
echo '<link href="//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic|Archivo+Black" rel="stylesheet" type="text/css" />';
}
@ramseyp
ramseyp / s25_author_box.php
Created January 12, 2013 18:46
Add an author box to an author archive in a Genesis child theme. Place this in your functions.php for your child theme.
<?php
/**
*
* Add author box before the loop on an author archive.
* Grabs the ID from the query. On an author archive, this the author ID.
* get_the_author_meta() is used to retrieve the various meta: user_nicename, description, etc.
* http://codex.wordpress.org/Function_Reference/get_the_author_meta
*
*/
@ramseyp
ramseyp / multisite-custom-post-info.php
Last active December 10, 2015 16:18
Customize the Post Info on a Genesis child theme in a multisite environment for a specific blog.
<?php
/**
*
* Customize Post Info on a specific multi-site blog
*
* http://wordpress.org/support/topic/how-to-get-current-site-blog-id?replies=9#post-1610948
* http://my.studiopress.com/snippets/post-info/#customize
*/
add_filter( 'genesis_post_info', 'post_info_filter' );
@ramseyp
ramseyp / clear_credits_text.php
Created January 1, 2013 03:22
Remove Default Credits Text in StudioPress Child Themes
<?php
/**
*
* Remove Default Credits Text in StudioPress Child Themes
*/
add_filter( 'genesis_footer_creds_text', 'custom_footer_creds_text' );
function custom_footer_creds_text() {
echo '';
}