Categories
WordPress

Limiting Revisions in WordPress

If you spend a lot of time revising a page or a post, you can build up quite a number of revisions in the database.

The following line in the wp-config.php file in the root of the site will limit the number of revisions saved to 5. You can use whatever number you want, within reason.

define('WP_POST_REVISIONS', 5);

Other tricks using the wp-config.php file can be found at http://digwp.com/2009/06/wordpress-configuration-tricks/.

Categories
WordPress

Quickly move a WordPress blog to a new Host or Domain

Moving a WordPress blog to a new domain    or web host may be easier than you think.

  1. In the blog to be moved, select “Tools” in the left sidebar of your Dashboard.
  2. Now select the “Export” option to download the contents of the blog (posts, pages, comments, custom fields, categories, and tags) in an XML export file.
  3. Prepare your new WordPress installation on the new server with the appropriate theme and any plugins.
  4. In the dashboard of the new blog go to “Tools” and select “Import”.
  5. Choose the “Wordpress” option.
  6. Browsing to and select the XMS file you exported from the original blog, then click “Upload and Import”.

That's all there is to it.  Don't forget to redirect your domain to the new server if applicable.

Categories
WordPress

Updating WordPress

Periodically WordPress  must be updated.

You can determine the current version of WordPress by looking at the source code of the a post.  (Right-Click on the page and select View Page Source.)  You'll see a line similar to the following approximately 20 lines down.

Once in the WordPress Dashboard you will see a message like "WordPress 2.8.4 is available! Please update now." across the top if an upgrade is due.

Users reasonably comfortable with MySQL and with access to the server should install the MySQL Administrator and MySQL Query Browser from the MySQL Website to assist with database management.  It's a much easier way to work with your database, and it's not all that complicated.  I find MySQL Administrator a much easier way to work with databases that a web-based tool like phpMyAdmin.

Follow the following process to do the backup.

  • If you're using phpMyAdmin, use your webhost's control panel to access  phpMyAdmin and backup your database.
  • If you use MySQL Administrator to create a backup of the database.
    • Select Backup from the upper left pane; Select the WordPress Backup from the projects list in the lower left pane, click Execute Backup Now in the bottom right corner.
    • (If a backup project is not listed, click New Project, enter the name WordPress Backup, select your WordPress database in the schemata list, click [>], click Save Project.)
  • Backup necessary WordPress Files.
    • Typically it is only necessary to make a backup of the of the /wp-content/ folder, though a full backup of the site can be made.
    • Make a copy of the /wp-content/ folder in the wwwroot share.  Rename the copy of the folder to reflect the existing version number, i.e. if the existing version (see above to find the version) is 2.8.4, the copy of /wp-content/ will become /wp-content.284.disabled/.
  • Update WordPress
    • Click the Please update now link at the top of the WordPress dashboard and follow the instructions.
    • Visit any blog post, you'll be prompted to update the database.  Proceed with the database update, despite the warning of several minutes it will only take a few seconds.
Categories
CSS PHP WordPress

Changing the font of code blocks with geshi syntax highlighter

By default, geshi-derived syntax highlighters use a serif font to display code blocks.  Many people find serif fonts less clear than the visually simpler sans-serif fonts.

A good choice is Lucida Console.  Consolas is even better because it has a slashed zero, which is easier to distinguish from the capital letter "O", though not as many computers have Consolas installed. To account for this, list the fonts in order of preference, the browser will use the first one that it can display.

To change the default font for code blocks, find the geshi code folder (usually under plugins), open geshi.php and look for the following code:

1
2
3
4
5
    /**
     * The overall style for this code block
     * @var string
     */
    var $overall_style = 'font-family:monospace;';

And modify is as seen here. Note that two word font names must be quoted, and the quote marks may need to be escaped, as seen below;

1
2
3
4
5
    /**
     * The overall style for this code block
     * @var string
     */
    var $overall_style = 'font-family:Consolas, \'Lucida Console\', monospace;';
Categories
WordPress

Fixing the space between < and ?php in source code blocks

WordPress can have the disconcerting habit of inserting a space between the < and ?php when you want to show a code block in a syntax-highlighter plugin. To cure this, go into your WP Admin page, select the Settings menu, Select the writing submenu, then uncheck the WordPress should correct invalidly nested XHTML automatically option.