Skip to content

Instantly share code, notes, and snippets.

Avatar
somone said this would be easy. someone LIED.

Norcross norcross

somone said this would be easy. someone LIED.
View GitHub Profile
View head_redirect.php
<?php
add_action ('wp_head', 'rkv_new_redirects', 1); // create redirects
function rkv_new_redirects() {
$newurl = 'http://mynewurl.com';
$slug = basename(get_permalink());
$cat = get_query_var('cat');
$cat_s = get_category ($cat);
$c_slug = $cat_s->slug;
// set up
@norcross
norcross / rkv-media-link
Created Jun 19, 2012
Change default linking WP media
View rkv-media-link
View Image-Waterfall.php
// let's go through and get the right image
function dg_thumb_waterfall() {
global $post;
if ( has_post_thumbnail($post->ID) ) {
echo '<div class="thumbnail-wrapper">';
the_post_thumbnail('digi-med-thumb');
echo '</div>';
@norcross
norcross / old-post-search-filter.php
Created Jul 23, 2012
filter search result to hide old posts
View old-post-search-filter.php
function rkv_search_filter( $where = '' ) {
// don't touch anything outside of a search query
if(is_admin() || !is_search() )
return $where;
// Hide posts older than 2 years old
if ( is_search() ){
$where .= "AND post_type = 'post' AND post_date >= '" . date('Y-m-d', strtotime('-730 days')) . "'";
return $where;
}
@norcross
norcross / format-content
Created Jul 26, 2012
format text from custom call
View format-content
global $post;
$content = $post->post_content;
echo wpautop($content);
@norcross
norcross / jquery.radioset
Created Aug 1, 2012
allow labels to set input for radio and checkbox
View jquery.radioset
// **************************************************************
// set inputs when clicking labels
// **************************************************************
$('div#default_license span.ap_option label[rel="ap_rd"]').each(function() {
$(this).click(function() {
if($(this).hasClass('disabled-label'))
return;
@norcross
norcross / image-url-fix
Created Aug 10, 2012
create clean attachment URLs
View image-url-fix
// clean URLs for attachments
// http://domain.com/?attachment_id=173
// http://domain.com/attachment/173
function rkv_attachment_urls($wp_rewrite){
$new_rules = array();
$new_rules['media/(\d*)$'] = 'index.php?attachment_id=$matches[1]';
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
View amm-change-title
<?php
function amm_change_title($title) {
global $post;
$type = get_post_type( $post->ID );
$slug = basename(get_permalink( $post->ID ));
if( 'page' == $type && 'title-test' == $slug )
$title = esc_attr( 'My Awesome Title' );
@norcross
norcross / shopp-comment-hide.js
Created Aug 14, 2012
Hide comments and pingbacks on Shopp
View shopp-comment-hide.js
jQuery(document).ready(function($) {
//********************************************************
// expand / collapse for settings page
//********************************************************
$('div.settings_group div.dg_wrap').hide();
// show or hide new license block licenses
$('div.settings_group input.toggle_group').click(function() {
var name = $(this).attr('name');
@norcross
norcross / mc-campain-list.php
Created Aug 17, 2012
MailChimp Campaign List
View mc-campain-list.php
function mc_campaign_content($cid) {
$apikey = 'APIKEY';
$method = 'campaignContent';
$archive = 'true';
$request = new WP_Http;
$url = 'http://<dc>.api.mailchimp.com/1.3/?method='.$method.'&apikey='.$apikey.'&cid='.$cid.'&for_archive='.$archive.'&output=json';
$response = wp_remote_get ( $url );