Thursday, February 10, 2011

Random Wordpress Notes

We're converting our website to WordPress (which I continue to be impressed by, but that'll be another post). One or two random notes.

If you put your news feed 'on a page' the page template is ignored - index.php is still used. I am sure this is by design, but I discovered it while creating a custom template. The page contents appear to be ignored too.

If you have an existing site and you want to merge in WordPress, you can do this:
  • Host your news feed on a specific page, rather than letting it default to 'home'.
  • Change the WordPress URL base (not install base) to your site.
  • Put a mod_rewrite rule into your site root to rewrite missing files to /wp/index.php (or wherever WP is installed).
  • If you want to replace an existing HTML page with a WP page you can use a rewrite rule from the old name to something like /wp/index.php?page_id=20 (or whatever page ID you want).
This is similar to the normal 'changing base' rules for WP, except that you don't need to create a second index.php in your root folder - your old site's home page stays in place.
RewriteEngine On
RewriteRule news.html /wp/index.php?page_id=5 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
mod_rewrite is pretty cryptic. Basically what this says is:
  1. If the user asks for news.html, go to WordPress article 5.
  2. If the user asks for a missing file, let WordPress sort it out.

No comments:

Post a Comment