Wordpress

Wordpress is the standard Content management system. Quick to install and requiring relatively low resources, it is very popular. Here you will find tips and thoughts I gathered from my experience using Wordpress. [sb_child_list]

Wordpress: Enable multi site

Will expand at some point but here is the gist of it: mkdir wp-content/blogs.dir chmod 777 blogs.dir
  • First enable multi site on config
define('WP_ALLOW_MULTISITE', true);
  • enable in tools/network - In admin, installs asks to add this/ asked by install
  • Modify wp-config.php:
define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); $base = '/'; define('DOMAIN_CURRENT_SITE', 'blog.webdevpower.com'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 1);
  • enable plugins
  • modify .htaccess
RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L]   # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*.php)$ $1 [L] RewriteRule . index.php [L]

10 wordpress plugins

Here are a few plugins I use on most wordpress installs:
  • Akismet - Due to wordpress' popuplarity, many spammers will visit your website. This antispam plugin comes standard and is free for personal use. You will have to retrieve a key first using a wordpress account first though
  • Posts 2 posts - allows many to many relationships between posts with optional link info
  • Fast Secure Contact form - quick contact forms sent via email. A nice companion plugin is the to use is the database storage plugin to store entries to a database.
  • Custom content type manager - easily add multiple content types. The nice part about it is multiple content types get their entry in the dashboard and it provides multiple custom field types that are repeatable.
  • Google analytics - keep track of visitors
  • Google adsense - put ads in your websites
  • W3 Total cache - when performance issues arise, this helps
  • WP Mail SMTP - Many hosts either provide no mail server or their ip is blocked from sending mail. This plugin allows to send email via an alternate provider such as gmail
  • Wordpress SEO - this plugin, among others, rewrites headers to be more search engine friendly. An alternative is All in one SEO pack which has been around much longer but has been losing in popularity.
  • next gen gallery - for all times you need to add picture galleries, this is a good option. Many extensions to add flexibility exist such as voting.

Moving wordpress install across domains

As wordpress hardcodes urls to posts in the database, it can be very annoying when you alternate between a production and a dev server. Luckily, it is possible to overwrite this global url by specifying two lines in wp-config:
define('WP_SITEURL', 'http://www.mynewsiteaddress.com/');
define('WP_HOME', 'http://www.newsiteaddress.com/');
Please note that some plugins that use the file system like ssome caches may have to be reconfigured or the cache may be reconfigured. Rather than hardcoding the domain name, you can even use $_SERVER['HTTP_HOST']; Alternatively, you can replace the values in the database with the search and replace plugin http://wordpress.org/extend/plugins/search-and-replace/ . Note, some images in the database such as 2011 theme header images or absolute link will not be affected by this trick. To avoid problems, I suggest using relative urls (most importantly, avoiding putting in the domain name).

Child Themes

If you want to heavily customize your themes, you probably want to start with themes such as blank slate or twitter bootstrap. However, for a quick prototype or if your need are relatively simple, you can override wordpress's base themes (2012 and 2011) relatively easily and the nice thing a lot of things are customizable from the admin. To Create a child theme, simply create an empty directory with your theme's name and put the following in a file called style.css:
/*
Theme Name: Your child theme name
Theme URI: http://www.example.com
Description: This is my child theme
Author: Your name here
Author URI: http://www.yoururlhere.com/
Template: twentyeleven
Version: 1.0
*/