Twenty Twelve Title Contain No Spaces

There is a conflict between the Twenty Twelve WordPress and the All in One SEO Pack plugin. When the plugin is installed and you happen to be using the Twenty Twelve theme, the result is, there will be no space between your site title and blog title. You’ll notice this if you look at the title bar of your browser. After a couple of searches, I found a fix online. It involves editing the Twenty Twelve functions.php file and commenting out line 185 which contains the code below.

You will need to change:

add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

and comment out:

// add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

Also, you need to clear your browser cache to see results.

Tricky WordPress Multisite Setup

I was converting a regular WordPress blog to a Multisite blog the other day. I got stuck in the part where I needed to edit the wp-config.php file. I applied the changes to wp-config.php as suggested in the installation instructions. The problem was I wasn’t seeing the Multisite menus you would normally find under ‘My Sites’ inside the WordPress Dashboard. The installation instructions tells you to add the following lines to your wp-config.php file.

/** Enable WordPress Multisite */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
$base = '/';
define('DOMAIN_CURRENT_SITE', 'domain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

It was a silly mistake on my part. I placed these entries at the end of the wp-config file. It is important that these lines remain above the absolute path statement and before the wp-settings are loaded. See below.

/* That's all, stop editing! Happy blogging. */
 
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/');
 
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

Keep these lines at the end of the wp-config.php file.

WP-Admin Trailing Slash Problem

I had this WordPress wp-admin trailing slash problem for a couple of weeks now. When I don’t include a trailing slash after the wp-admin directory when logging in to WordPress, I will get a 404 missing page error. It’s a little annoying if you ask me, but it doesn’t really affect blog readers. It only shows up if you want to login to the WordPress Dashboard, and you forget to type the trailing slash at the end of wp-admin. Example below.

site.com/wp-admin/ <– this redirects to the WordPress login ok.
site.com/wp-admin <– this will result in a 404 missing page error.

So, I tried a couple of suggestions I found online, but the suggested changes to the .htaccess file didn’t seem to fix the issue. A couple of occasions, the suggestions were exactly the same code I already had in my .htaccess file. So, I tried a couple more suggestions. I noticed one blog post had a couple more lines in the .htaccess file that I haven’t seen in mine. So, I tried it and it worked. So, here are the changes I made.

I added these two lines to my .htaccess.

RewriteEngine On
RewriteBase /

I think the key code is in the second line. It basically establishes the base URL.

Regain Your WordPress Admin Account

So, I decided to get cute and changed my WordPress admin username to a username I wanted via a utility called phpMyAdmin. I went to the wp_users table and made a simple username change to the user_login field. I logged out and logged in back to the WordPress Dashboard. Disaster! I just lost both my WordPress admin and network admins rights. My former admin account has been reduced to a regular plebe. So, this is how a regular WordPress subscriber looks like.

It was a scary five minutes at WordPress land. I’m laughing now, but I wasn’t then. So, I went back to phpMyAdmin and also changed the user_nicename and display_name to the wp_users table hoping that would fix it. No cigar. Panic set in. After a few Google searches, I finally found the solution. Thanks to people who post their solutions online.

What a relief! First, you have to make sure you have the right user_id, especially if you have a multisite blog. Go to your wp_users table and make a mental note of your admin ID. It’s usually an ID of 1.

Next, I went to the wp_usermeta table and changed the wp_capabilities entry to a:1:{s:13:”administrator”;s:1:”1″;}.  The key here is the entry s:13. My account was reset to s:1 for some reason. I temporarily changed it to s:10, but it didn’t work. Setting it to s:13 did the trick. It worked wonderfully.

Now, I’ve regained all the admin rights for each blog that’s on the network, except that I’ve lost the Network Admin. Well, another Google search. Thank you. To make the story short, I also had to edit the wp_sitemeta table. Look for the meta_key and change to a:1:{i:0;s:11:”yournewname”;}. The s:11 is the length of “usernewname” which is 11.

That was the fix. Whew. A close shave. All in all, all is good once again at WordPress land. I am one happy admin. Just a bit on the adventurous side, but otherwise a happy camper. I’m posting this article because, I know some dufus admin in the future will probably do the same thing that I did. It wasn’t all that bad. It was just a little bit disconcerting when you lose all admin rights.

WordPress Blank Dashboard

I recently moved one of my blogs to Linode, a VPS hosting company. I noticed right away, when I logged in as admin, that the WordPress Dashboard, displayed a blank page. That’s not good. So, I started removing plugins by renaming the plugin directories until I found the offending plugin. Sure enough, it was a custom plugin I wrote myself.

Nothing has changed. The plugin hasn’t been touch. WordPress is the same latest version. The only thing that changed was the host server. So, I started looking into my PHP installation. What could possibly be missing? When I looked into my plugin code, I noticed some references to curl. I realized my server was missing a php5-curl module on the new host server.

A simple command to install php5-curl on the new server does the trick.

sudo apt-get install php5-curl

In this particular case, a missing module in PHP, caused the plugin to die unexpectedly, resulting in a blank Dashboard page within WordPress. Removing offending plugins temporarily fixes the issue, but it doesn’t get to the root of the problem. In my case, I was able to narrow it down to the missing PHP curl module that my plugin desperately needs.

In any case, everything is back to normal as expected, except for the blog, which is serving pages exceptionally fast, since I’m now running at Linode.

A New Theme

A new year, a new theme, a new framework, a somewhat familiar layout, and the same old background. The new theme is based on the Genesis framework by StudioPress. I’m using a child theme called News.

The new theme should be more flexible when it comes to layout and functionality. The Genesis framework is quite robust. The framework has a plugin called Simple Hooks that makes it easier to make theme customizations.

A piece of code can be inserted using Simple Hooks. It will accept any HTML, Javascript and PHP code. The hooks can do wonders when inserted in key sections of the framework. Plugins shortcodes can be inserted as well.

Overall, I’m still learning how to work with this framework works. The concept is a little foreign to what I am used to, but I like what I have done to the theme so far.

I hope you like the new theme.

2011 In Review

According to WordPress, I wrote a total of 190 posts in 2011. To see all the articles written in 2011, simply access:

http://ulyssesonline.com/2011/

This feature is possible using one of the nicest features in WordPress called permalinks, which is short for permanent links. With permalinks, you can customize your own URL structure the way you want it. I happen to use this format:

http://ulyssesonline.com/%year%/%monthnum%/%day%/%postname%/

which makes it easier for me to display articles by year, month and day. To access all articles written in 2011, I just provide the year and all articles written in 2011 will be displayed. Most WordPress users already use permalinks.

If you are not, do it early. Over the years, you’ll see the benefit of using such a structure.

Close Comments After X Amount Of Days

One thing I recently implemented on my WordPress blog is to close comments on posts older than 30 days. After 24 hours, I noticed my spam comments has dropped dramatically to zero. That’s a good thing.

To close comments on posts after x amount of days, all you have to do is access your WordPress Dashboard > Settings > Discussion page. Look for the option saying “automatically close comments older than  x days.” Here’s a snapshot of the page.

Snapshot

Just check it to turn on the feature. Supply the number of days that you want the comments to be turned on. Comments will be turned off on posts older than x number of days that you’ve provided. Simple enough. This is just another tool to help lower your blog’s spam comments. It certainly did on my blog.

Turning Off Post Revisions in WordPress

Post Revision is a WordPress feature that was introduced with WordPress version 2.6. Post revisions allowed WordPress users to go back to previous saved versions of a post. It’s a life-saving feature to those needing to roll back to a previous post.

Although this feature have saved countless individuals from potential lost work, it also can add some overhead to the database tables because it inserts a new record every time a post is saved.

I was more than curious to how much data could be saved if post revisions were deleted from the database. So, I embarked on a project to delete post revisions from my main blog, which happens to be a multi-site blog.

Prior to doing anything, I recommend that you backup your database via PHPMyAdmin. Backup all the tables. This is very important. I can’t stress this enough.

I use the instructions from Lester Chan’s article to turn off and delete post revisions. I didn’t hesitate using Lester’s instructions because he is well-known and trusted member in the WordPress community having written many valuable plugins.

Turn Off Revisions

You can turn off revisions by editing your wp-config.php file and adding the following:

define('WP_POST_REVISIONS', false);

Delete Post Revisions

You can delete post revisions from the wp_posts table by running this SQL statement from PHPMyAdmin. You may need to repeat the process if you have a multi-site blog.

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';

Results

I have a total of 5 blogs running on my multi-site blog. Prior to deleting post revisions, my backup SQL file was 16.6MB. After deleting the post revisions, I was able to shave off 2.3MB. The file is now only 14.3MB. It doesn’t seem like a lot of saved space, although it deleted over 1000 rows.

Which brings me to the question, was it all worth it? Probably not. For the tiny amount of space saved, you are probably better off leaving post revisions alone, because you’ll never know if you need to revert to an older post. After all, it’s a nice feature to have.