Skip to content

Instantly share code, notes, and snippets.

Steven-Rose

Block or report user

Report or block Steven-Rose

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Steven-Rose
Steven-Rose / gist:1728857
Created Feb 3, 2012
MySQL: Update from another table
View gist:1728857
UPDATE from_table t1, to_table t2
SET t2.field_name = t1.field_name
WHERE t2.field = t1.field
@Steven-Rose
Steven-Rose / gist:1728846
Created Feb 3, 2012
Canonical redirect to non-www
View gist:1728846
# canonical redirect to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
@Steven-Rose
Steven-Rose / gist:1728801
Created Feb 3, 2012
WP: Update all permalinks
View gist:1728801
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
@Steven-Rose
Steven-Rose / gist:1728796
Created Feb 3, 2012
WP: Child posts referencing meta value
View gist:1728796
$pages = get_pages('child_of='.$post->ID.'&meta_key=key&meta_value=value&sort_column=menu_order');
@Steven-Rose
Steven-Rose / gist:1728787
Created Feb 3, 2012
WP: Query for current author ID
View gist:1728787
/**
* Query DB for current author ID
*
* @global class $wpdb Global WordPress Database class
* @param String $author Author name from URL, identical to user_nicename in users table
* @return String User ID of author
*/
function get_author_id( $author ) {
global $wpdb;
$author_id = $wpdb->get_results( "SELECT `ID` from $wpdb->users u WHERE u.`user_nicename` = '$author'" );
@Steven-Rose
Steven-Rose / gist:1728775
Created Feb 3, 2012
WP: Set theme image sizes
View gist:1728775
add_theme_support( 'post-thumbnails' );
add_theme_support( 'page-thumbnails' );
set_post_thumbnail_size( 320, 240, true ); // Normal post thumbnails
add_image_size( 'list-display-thumbnail', 300, 225, true ); // Permalink thumbnail size
add_image_size( 'main-display-thumbnail', 660, 300, true ); // Permalink thumbnail size
add_image_size( 'tiny-display-thumbnail', 100, 60, true ); // Permalink thumbnail size
add_image_size( 'training-small-thumbnail', 235, 150, true ); // Permalink thumbnail size
add_image_size( 'blog-small-thumbnail', 150, 150, true ); // Permalink thumbnail size for blog
add_image_size( 'secondary-image-clients-thumbnail', 660, 300, true);
@Steven-Rose
Steven-Rose / gist:1728768
Created Feb 3, 2012
WP: Remove extra contact methods from user info
View gist:1728768
function remove_contact_methods( $contact_methods ) {
unset($contact_methods['yim']); // Remove Yahoo IM
unset($contact_methods['aim']); // Remove AIM
unset($contact_methods['jabber']); // Remove Jabber
return $contact_methods;
}
add_filter('user_contactmethods','remove_contact_methods',10,1);
@Steven-Rose
Steven-Rose / gist:1728766
Created Feb 3, 2012
WP: Custom admin favicon/logo
View gist:1728766
add_action('admin_head', 'custom_logo');
function custom_logo() {
echo '<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/favicon.ico) !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
function custom_login_logo() {
echo '<style type="text/css">
@Steven-Rose
Steven-Rose / gist:1728760
Created Feb 3, 2012
WP: Disable default link addition when inserting image into post
View gist:1728760
update_option('image_default_link_type' , 'none');
@Steven-Rose
Steven-Rose / gist:1728753
Created Feb 3, 2012
WP: Remove header info (potential for SEO path issues)
View gist:1728753
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feedremove_action( 'wp_head', 'start_post_rel_link'); // Removes the start link
remove_action( 'wp_head', 'start_post_rel_link'); // Removes the start link
remove_action( 'wp_head', 'wp_shortlink_wp_head' ); // Removes shortlink reference
remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
You can’t perform that action at this time.