WordPress is a great blog application, this page is for the tweaks and pluggins that I use and like to have around.
- Google Sitemap
- Advanced Excerpt, apart from better default tags that are allowed, this should be the default on WordPress.
- Super Cache, another thing that should be included by default in some way.
- Bad Behaviour, stop spammers posting in the first place, a good first barrier before Akismet.
- Subscribe to comments
- Warn people that their comment is caught
- Feed stats
- My latest tweet, displays your last twitter tweet, from Eric Meyer.
Also see further information on combining wordpress pluggins to prevent spam.
WordPress is begging for a good OpenID pluggin, I’m not sure if this OpenID pluggin is it (quite a few dependancies), but probably worth a try.
I’ve just created one to improve the output of the gallery code in WordPress 2.5. Hopefully I can ‘bug’ this and get it updated for a later release.
Arranging the navigation in a blog is something of an art form. A recent update (I think it is at least), it to allow the display of sub-pages in a section only.
I’ve found that updating by SVN is a real time saver, removing the whole FTP process. I leaves the wp-content directory alone, so once you’ve got it setup with:
svn co http://svn.automattic.com/wordpress/tags/2.3.3/ .
(The dot at the end means the current directory, rather than creating a sub-folder.)
Updates are as simple as running this on the command line in the HTML root directory:
svn sw http://svn.automattic.com/wordpress/tags/2.3.3/
(Where 2.3.3 is the latest version). Then you just run the upgrade script:
Getting 404’s to provide the correct header
For some reason wordpress’ default 404 page sends out a ‘200’ everything’s ok HTTP header. Not good. However, adding this to the head of the 404 template sorts it out:
<?php header("HTTP/1.0 404 Not Found"); ?>
Highlighting author’s comments
To add a class to your own comments, simply use an
if statement in the class attribute’s value”, usually in
comments.php in your theme. The whole
li would then be (on one line):
<li class="<?php echo $oddcomment; if ($comment->comment_author_email == "email@example.com") echo ' author'; ?>" id="comment-<?php comment_ID() ?>">
Note the space before the
author class. (Originally found from a WordPress support post, but altered slightly.)
Changing the website domain
If you have a local version of your blog running, you can copy the files and database happily enough (e.g. with
mysqlhotcopy), but WordPress re-writes all the links based on the database entry for your URL.
You could change that in the settings, but it’s really difficult to get to, I prefer to change it in the database. Log into MySQL (usually with
mysql -u root -p), then do this:
mysql> use YourDataBaseName; mysql> select option_value from wp_options where option_name = 'home'; mysql> update wp_options SET option_value='http://NewLocation' where option_name = 'home'; mysql> update wp_options SET option_value='http://NewLocation' where option_name = 'siteurl';
NB: Change the value of
NewLocation to your new URL. Those commands show you the current location, then set the base URL, then the homepage (which can be different, but usually isn’t).
The other way of doing it is in the
wp-config.php, which overrides the database settings, which is probably a better option for transporting sites. Add these with the other ‘define’ statements:
define('WP_SITEURL', 'http://example.com'); define('WP_HOME', 'http://examples.com');
The codex page on wp-config is quite useful for this and other configurations.
Exporting the content as HTML
By default WordPress will export the content & excerpts as mark-down crossed with HTML, i.e. missing the paragraph tags. I wasn’t to keen on this, so found the function that displays the content in the site, and applied that to the export.
If you open the file /wp-admin/includes/export.php, look for two lines that begin with:
Then you are basically adding the function
wpautop to that. In the last version of WordPress I used (around 3.0) I did that with:
<content:encoded><?php echo wxr_cdata( apply_filters( 'the_content_export', wpautop($post->post_content) ) ); ?></content:encoded> <excerpt:encoded><?php echo wxr_cdata( apply_filters( 'the_excerpt_export', wpautop($post->post_excerpt) ) ); ?></excerpt:encoded>
NB: The lines above are long so you can copy-paste, but you might need to scroll right to read it. That should make the exported XML file use HTML.
Making WordPress a library
Most of the steps in the codex (Giving WordPress its own folder) will do the job, however, there is one gotcha if you’d like to use WordPress as a library (i.e. run several blogs off one install).
If you put WordPress somewhere several sites can use and create a SymLink to WordPress, it will still look for the wp-config.php in the folder where WordPress is, not the folder your site is in.
To solve this, add your wp-config.php in your site’s root, and then create wp-config.php in your wordpress folder, and put this in it:
<?php include $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' ?>
The other gotcha is that you need to fill in the Misc settings, and put the full directory path to your uploads folder.
Styling your RSS feed
If someone clicks through to your RSS feed, it’s pretty confusing to see a straight XML file. You can use XSL to provide a nice page and instruction on how to use the feed.