How to Fix: WordPress Admin Dashboard Does Not Appear After Upgrade

Problem: You update/upgrade WordPress to a new version. All looks great until you log into the admin area. You get a error page and the page redirect to a url that includes “/wp-admin/upgrade.php?_wp_http_referer=%2Fwp-admin%2F”.

Fix: After clearing cache and the usual errors, there is another possible culprit. The db_version in the database and in the config files do not match. To fix this, open the database in PhpMyAdmin, in the wp_options table, look at the db_version field. Now FTP to the site, and look at the wp_db_version variable in the file /wp-includes/version.php files. If they do not match, this is your likely problem. In most cases, the database needs to be edited to match the version in the file. Change the version number in the database, then open the WP admin in a new browser and try to login again. Hopefully this solves your problem.

SQL Code For Changing WordPress URL

Code to use for replacing urls in wordpress database:

UPDATE wp_posts SET guid = replace(guid, '','');
UPDATE wp_posts SET post_content = replace(post_content, '', '');
UPDATE wp_links SET link_url = replace(link_url, '', '');
UPDATE wp_links SET link_image = replace(link_image, '', '');
UPDATE wp_postmeta SET meta_value = replace(meta_value, '', '');
UPDATE wp_usermeta SET meta_value = replace(meta_value, '', '');
/*UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';*/
UPDATE wp_options SET option_value = replace(option_value, '', '');

Add a Driving Directions Form to a Website

This code adds a small field to enter an address, plus a “Get Directions” button. The results are shown as Google Maps directions.

Be sure to edit your destination address in the code.

<form action="" method="get" target="_blank">
   <label for="saddr">Enter your location</label>
   <input type="text" name="saddr" />
   <input type="hidden" name="daddr" value="101 Main St, Tampa, FL 33615" />
   <input type="submit" value="Get directions" />

Remove Unnecessary Code From WordPress Header

WordPress uses the function wp_head() to add a bunch of code to the header of each page. Some of it is not absolutely necessary. This is especially true when using WordPress as a small business CMS, instead of a blog.

The code below removes the unnecessary code. Just add these to the end of your functions.php file.

This code applies to WordPress 3.0 and higher:

remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

This code applies to WordPress versions before 3.0:

remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');

CSS to Force a Scrollbar to Appear in IE8 and FF

Websites sometimes appear “shift” side-to-side a bit when you go from one page to another within the same website. This is usually caused by going from a page with a scrollbar to a page without a scrollbar, and vice-versa. The scrollbar appearing and disappearing causes the page width to be slightly different, thus the shifting appearance. This is usually seen in FireFox and IE8 browsers, due to how they render pages.

So as a web developer, how do you fix this? Simple. Add this single line to your css:

html { overflow-y :scroll }

This forces a non-active scrollbar to appear on pages that would otherwise not need a scrollbar.

How to Embed and Display YouTube Videos on a Secure SSL Page

EDIT: 5/11/2018: The problem of embedding youtube videos in an SSL page is no longer a problem like it was in 2010 when I originally wrote this post. Youtube is now ssl enabled. And with Flash Player embedding an ancient memory, it is best to just embed using the YouTube iframe method.

I’ve found that this variation of code works the best to size and display the embedded iframe video:

.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } 
.embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
<div class='embed-container'>
<iframe src='' frameborder='0' allowfullscreen>


EDIT 08/03/2010: A reader just pointed out that the method outlined in this post will present a warning in in the status bar when using the latest version of FireFox. No popups or dialog messages though – that’s good. And it still works flawlessly in IE and Chrome. Thanks to Jayapal for pointing the warning in FF.

Original Post:
Here is a cool trick to get rid of ssl security warning errors when embedding youtube videos into secure web pages.

This solution will work if your server is using Apache and has Mod_Rewrite enabled (most Linux web hosting companies do).

First, add this to your .htaccess file: Continue reading How to Embed and Display YouTube Videos on a Secure SSL Page

How To Disable Post Revisions in WordPress

Since WordPress 2.6, everytime you save a post, it is saved as a revision. All previous revisions are also saved. So, 10 revisions to a post will end up with 11 posts in the database. If you don’t need this revision history, and want to slim your database, add this code to your functions.php file:

define('WP_POST_REVISIONS', false);

Now, if you database is already full of previous revision, and you want to delete those form the database, also run this sql statement on the database:

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'