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, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_url = replace(link_url, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_image = replace(link_image, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
/*UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') 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, 'http://olddomain.com', 'http://newdomain.com');

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:

<?php
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:

<?php
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');
?>

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'

Stop WordPress from Removing br and p Tags

WordPress has a bad habit of removing or reformatting br and p tags that are entered into posts and pages. It also does some other funky formatting that can be annoying at times.

Well, here’s a way to fix this issue.

Go into the theme editing area of WP admin. Add this code to your functions.php file, and save it.

<?php
function my_formatter($content) {
	$new_content = '';
	$pattern_full = '{(\[raw\].*?\[/raw\])}is';
	$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
	$pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);

	foreach ($pieces as $piece) {
		if (preg_match($pattern_contents, $piece, $matches)) {
			$new_content .= $matches[1];
		} else {
			$new_content .= wptexturize(wpautop($piece));
		}
	}

	return $new_content;
}

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');

add_filter('the_content', 'my_formatter', 99);
?>

Now, when writing a post/page, use [raw][/raw] tags to surround that parts of the post/page that you do not want formatted.

WordPress 2.5.1 Upgrade: Changed Files 2.5 to 2.5.1

Disclaimer
I cannot stress the crtical importance of making a full backup of your files and database before attempting to upgrade WordPress. Mistakes do happen, and things do break. Both are shortly followed by you banging your head and cursing. Save yourself the headache…Backup first, then upgrade! 🙂

I should also mention that these files are being downloaded directly from the WordPress Trac system. I did not package the zip.

WordPress 2.5.1 was released.

Here is a zip of the files changed from WordPress 2.5 to 2.5.1.

WordPress – Best of Breed

It’s a simple as the title of this post…”Best of Breed”. When it comes to online blogging applications, WordPress is Best of Breed.

It’s free! But that does not make it great, just easily accessible.

It has a huge following! Have a WordPress question? It’s answered in a couple hours on their forum. Need some advanced help? You can find easily a WordPress pro online in minutes. Need some special feature? There’s a very good chance that someone else as already had that need too. You’ll likely find that there is a plugin already written for your feature.
Continue reading WordPress – Best of Breed