Skip to content

Instantly share code, notes, and snippets.

@nciske
nciske / change_post_menu_label.php
Created April 26, 2012 17:29
WordPress Change Post to Article
<?php
/* Change Post to Article */
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Articles';
$submenu['edit.php'][5][0] = 'Articles';
$submenu['edit.php'][10][0] = 'Add New';
$submenu['edit.php'][16][0] = 'Tags';
@nciske
nciske / custom-login-error.php
Created June 9, 2012 13:15
Custom Login Error Plugin
<?php
/*
Plugin Name: Custom Login Error
Plugin URI: http://www.thoughtrefinery.com/
Description: Customize error messages on login form
Version: 0.1
Author: Nick Ciske | Thought Refinery
Author URI: http://www.thoughtrefinery.com/
*/
@nciske
nciske / gist:3191934
Created July 28, 2012 05:34
Redirect One Domain To Another Using Mod_rewrite
#http://www.dzone.com/snippets/redirect-one-domain-another
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.old-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]
@nciske
nciske / custom_rss_teaser.php
Created August 10, 2012 21:04
Truncate WordPress RSS feed at <!--more--> tag
/*
http://www.peterrknight.com/how-to-truncate-your-wordpress-rss-feed-at-the-more-tag/
This functions display a custom teaser, by finding the teaser content using preg_split. It then appends a custom more link and returns the filtered content which then will show up in your RSS feed.
*/
function custom_rss_teaser( $content ){
$teaser = preg_split( '/<span id\=\"(more\-\d+)"><\/span>/', $content );
$readmore = '<p><a href="'.get_permalink().'">Read More</a></p>';
$content = $teaser[0].$readmore;
@nciske
nciske / parse_youtube_videoid.php
Created August 24, 2012 14:58
Parse YouTube Video ID from url
// http://stackoverflow.com/questions/2936467/parse-youtube-video-id-using-preg-match
function my_get_youtube_videoid( $url ){
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
return $match[1];
}
}
@nciske
nciske / run_embed_shortcode.php
Created September 3, 2012 21:42
WordPress Run oEmbed Shortcode
// http://wordpress.org/support/topic/call-function-called-by-embed-shortcode-direct
// Doesn't work:
// $post_embed = do_shortcode('[embed]your-video-url[/embed]');
// Does work:
global $wp_embed;
$post_embed = $wp_embed->run_shortcode('[embed]your-video-url[/embed]');
@nciske
nciske / witp2embed.html
Created September 14, 2012 15:35
Watch It Too iFrame Embed for P2
wrh-889 is the meeting id in this case (from WatchItToo) - change that to show different 'rooms' on different sites (or if you start a new meeting and want to post it).
708px wide (page)
<IFRAME FRAMEBORDER="0" SCROLLING="NO" MARGINWIDTH="0" MARGINHEIGHT="0" WIDTH="708" HEIGHT="860" src="http://watchitoo.com/iframe.php?id=wrh-889&scale=false&width=708&height=860&layout=12">Browser does not support iframes!</IFRAME>
640px wide (front page/status)
<IFRAME FRAMEBORDER="0" SCROLLING="NO" MARGINWIDTH="0" MARGINHEIGHT="0" WIDTH="640" HEIGHT="860" src="http://watchitoo.com/iframe.php?id=wrh-889&scale=false&width=640&height=860&layout=12">Browser does not support iframes!</IFRAME>
@nciske
nciske / get_meta_values.php
Created September 18, 2012 17:40
WordPress Getting all values for a custom field key
// http://wordpress.stackexchange.com/questions/9394/getting-all-values-for-a-custom-field-key-cross-post
function get_meta_values( $key = '', $type = 'post', $status = 'publish' ) {
global $wpdb;
if( empty( $key ) )
return;
$r = $wpdb->get_col( $wpdb->prepare( "
SELECT pm.meta_value FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
WHERE pm.meta_key = '%s'
@nciske
nciske / mailto-subkect-post-title.php
Created November 27, 2012 16:23
Mailto Link with Post Title as Subject
<a href="mailto:YOUR@EMAIL.COM?subject=<?php echo urlencode( get_the_title() ); ?>">LINK TEXT HERE</a>
@nciske
nciske / single.php
Last active December 10, 2015 11:38 — forked from billerickson/single.php
// Remove Genesis Author Box and load our own
remove_action( 'genesis_after_post', 'genesis_do_author_box_single' );
add_action( 'genesis_after_post', 'be_author_box' );
/**
* Load Author Boxes
*
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-post-multiple-authors/
*/