Skip to content

Instantly share code, notes, and snippets.

building things

Chuck Reynolds chuckreynolds

building things
Block or report user

Report or block chuckreynolds

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
chuckreynolds / wp-clean-transients-trackbacks-revisions.sql
Created Feb 28, 2013
removes transients temporary stuff - removes all pingbacks/trackbacks - removes all post revisions 1. comment out or just don't copy certain lines if you don't want to remove that stuff 2. remember to change the wp_ prefix to whatever yours is if you've modified it from default
View wp-clean-transients-trackbacks-revisions.sql
DELETE FROM wp_options WHERE option_name LIKE '_transient_%';
DELETE FROM wp_comments WHERE wp_comments.comment_type = 'pingback';
DELETE FROM wp_comments WHERE wp_comments.comment_type = 'trackback';
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision';
chuckreynolds / wp-change-db-table-prefix.sql
Created Feb 28, 2013
Change Table Prefix's on WordPress Database Most client sites I redo have the default "wp_" table prefix and I like to change that to something random like "wp_fE4se_" (or whatever) for security reasons. 1) run the RENAME table on each and every table in your wordpress database to rename the table itself 2) Run the next two lines and change NEWP…
View wp-change-db-table-prefix.sql
RENAME table wp_commentmeta TO wp_NEWPREFIX_commentmeta;
RENAME table wp_comments TO wp_NEWPREFIX_comments;
RENAME table wp_links TO wp_NEWPREFIX_links;
RENAME table wp_options TO wp_NEWPREFIX_options;
RENAME table wp_postmeta TO wp_NEWPREFIX_postmeta;
RENAME table wp_posts TO wp_NEWPREFIX_posts;
RENAME table wp_terms TO wp_NEWPREFIX_terms;
RENAME table wp_term_relationships TO wp_NEWPREFIX_term_relationships;
RENAME table wp_term_taxonomy TO wp_NEWPREFIX_term_taxonomy;
RENAME table wp_usermeta TO wp_NEWPREFIX_usermeta;
chuckreynolds / wp-fix-curly-quotes.sql
Created Feb 28, 2013
SQL Statement Replace Smart Curly Quotes with Regular Quotes in WordPress. I was migrating an old wp site with a ton of content I noticed a lot of curly quotes / smart quotes and the curly single quotes. My OCD hates that and it's not proper and looks bad to bots so I wanted to batch change them all to regular ascii quotes. This statement handle…
View wp-fix-curly-quotes.sql
UPDATE wp_posts SET post_content = replace(replace(replace(post_content, '', '"'), '', '"'), '', '''');
chuckreynolds / wp-user-custom-fields.php
Created Feb 28, 2013
Custom WordPress User Profile Fields. Who EVER fills out the yim/aim/jabber fields in their wordpress profile? not me and not clients lol... in this, it removes those three fields and adds twitter, facebook and google+ profile url fields. How to add those those new fields to the front end is included in comments
View wp-user-custom-fields.php
// Add custom fields to user profiles
function vuurr_sm_contactmethods( $contactmethods ) {
// Add
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['googleplus'] = 'Google+ About';
// Remove
chuckreynolds / wp-rem-update-notify-admins.php
Created Feb 28, 2013
Remove WordPress Update Notifications Except for Admins
View wp-rem-update-notify-admins.php
global $user_login;
if (!current_user_can('update_plugins')) { /* checks to see if current user can update plugins */
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
chuckreynolds / wp-null-search-redirect.htaccess
Created Mar 7, 2013
Redirect empty searches in WordPress back to root. Empty ?s= suck and WP doesn't handle them. You should.
View wp-null-search-redirect.htaccess
# Redirect Empty Searches to root
RewriteCond %{QUERY_STRING} ^s=$
RewriteRule ^ /? [L,R=301]
chuckreynolds / yoast-wpseo-default-setup.ini
Last active Dec 14, 2015
For now this is my base setup for Yoast's WordPress SEO plugin - good import for basic technical setup in WP. NOTE: This is not an import and forget it type of thing. I HIGHLY STRESS that you still go through EVERY settings page and Tab in the Yoast SEO plugin settings and make sure you set it up for your exact needs. This is a good start but do…
View yoast-wpseo-default-setup.ini
; This is a settings export file for the WordPress SEO plugin by -
ignore_blog_public_warning =
ignore_tour = "ignore"
ignore_page_comments =
ignore_permalink =
ms_defaults_set =
version = "1.4.1"
tracking_popup = "done"
chuckreynolds / wordpress-activate-link-manager.php
Created Mar 25, 2013
In WordPress 3.5+ the removed what used to be known as "links" in the admin. For now... in order to reenable that... use this filter
View wordpress-activate-link-manager.php
chuckreynolds / wordpress-redirect-post-single-query.php
Created Apr 4, 2013
Redirect to post if a search only returns one post.. Just paste the following code snippet into your functions.php file:
View wordpress-redirect-post-single-query.php
add_action('template_redirect', 'redirect_single_post');
function redirect_single_post() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
chuckreynolds / wp-block-updates-after-time.php
Created Apr 26, 2013
Block WordPress Post Updates and Deletion After a Set Period. ganked from here as may need this in future....
View wp-block-updates-after-time.php
function wpbeginner_restrict_editing( $allcaps, $cap, $args ) {
// Bail out if we're not asking to edit or delete a post ...
if( 'edit_post' != $args[0] && 'delete_post' != $args[0]
// ... or user is admin
|| !empty( $allcaps['manage_options'] )
// ... or user already cannot edit the post
|| empty( $allcaps['edit_posts'] ) )
return $allcaps;
You can’t perform that action at this time.