MidnightCoder's Wordpress Blog

The MidnightCoder.ca Blog Site

Domain Mapping With WordPress 3 and cPanel

one comment

This will be a brief tutorial on getting underway with the Multi Site and Domain Mapping features of WordPress 3. It’s easier than it sounds, and WordPress 3 is light years beyond the early builds of WPMU that many of us tried, but ultimately abandoned as unreliable or unstable. I’ll be demonstrating how to set this up on a Linux server running cPanel control panel software, as this is what I use and prefer.

There are a few corners that can be safely cut using this method, saving a bit of time and some emails back and forth between you and your host. I’ll cover two scenarios. The first will apply if you are setting up Multi Site WordPress on the primary domain in your cPanel account, and the second will apply if you’re setting it up on an addon domain. The process is only slightly different for each.

So let’s get to it! First, you need an installation of WordPress 3 RC1 or RC2 (I’ll assume you already have that installed). Open up wp-config.php in your blog’s root directory, and add this line:

define('WP_ALLOW_MULTISITE', true);

Save the file, upload it to overwrite the old one if your editor doesn’t do that for you. Before we use the new settings created in your WordPress admin panel, we need to do some preliminary stuff like set up the wildcard dns entry for your domain.

As mentioned above, there are two possible scenarios here. One is if you’re setting this up on your primary domain, the other if you’re going to use an addon domain. There are notes at the end of this tutorial for dealing with setting up WordPress Multi Site on your addon domains.

Domain Mapping and Multi Site on Your Primary Hosted Domain

For setup on the primary domain on your cPanel account, start by opening the cPanel and clicking Simple DNS Zone Editor if it’s an option, or it may simply be DNS Zone Editor on some hosts. You should see something like this:

cPanel Simple DNS Editor

cPanel Simple DNS Editor

What we need to do now is to add a wildcard dns entry. This is an A Record which you should add in the format *.yourdomain.com and point to your site’s IP address. It should look something like this, but of course with your domain name and your website’s IP.

Adding a Custom A Record in cPanel

Adding a Custom A Record in cPanel

After submitting that, the new record should appear in the lower section of the page, and look like this:

Simple DNS Editor Custom Records

Simple DNS Editor Custom Records

You may also see other lines regarding your addon, parked or subdomains. As long as the new record you added is showing correctly, you can just ignore those right now.

The next step is easier than the last. Go back to the front page of your cPanel, and then to “Parked Domains“. Here you will add each domain you want to use with your Multi Site WordPress installation. In our example here, we will use this very blog to illustrate, as it is an extension of MidnightCoder.ca using these features. After you have added at least one Parked Domain, you should see something like this:

Parked Domains in cPanel

Parked Domains in cPanel

The last step here is to park a subdomain. This is the virtual subdomain that you will create your second WordPress site with. For our example we’ll just call it “blog.midnightcoder.ca”. It doesn’t much matter what it’s called, as the domain name you just parked will be how you and your visitors access it for all things but the admin panel of the blog. Don’t worry that the subdomain you’re parking doesn’t really exist. That will come into play later when we set up the network settings in WordPress.

Parked Subdomain in cPanel

Parked Subdomain in cPanel


Read the rest of this entry »

Written by MidnightCoder

June 8th, 2010 at 12:27 pm

Posted in Tutorials,WordPress 3

Tagged with , , , , ,

Permalink:

Shortlink:   

Add WordPress 3 Menu Support to Old Themes

leave a comment

This will be a quick and dirty fix to bring the new menu system in WordPress 3 to virtually any old theme you might be using. The vast majority of old themes are basically compatible with WordPress 3 out of the box, but a few new features like this require small changes to the theme code.

First, we want to update your theme’s functions.php file with the new functions, so open it in your favourite plain text editor, or code editor (but never a word processor) and add these lines. It doesn’t much matter where in the file you add them, and depending on the theme you’re using you may see a lot or almost no code in there. This is normal, the purpose of your theme functions.php file is to hold the extra scripting that is used only by your WordPress theme.

add_theme_support( 'nav-menus' ); // add menu support to your functions.php

// Add this where ever you want menus to show (ex: header)
wp_nav_menu('sort_column=menu_order&container_class=navigation');

// Target a specific menu
wp_nav_menu( array('menu' => 'Menu Name Here' ));

// Get the HTML list content for nav menu items
walk_nav_menu_tree('sort_column=menu_order&container_class=navigation');

Next we need to place the new menu in the front end of your theme. This will almost always be in /wp-content/[yourtheme]/header.php

There is a lot of variation in how WordPress themes are designed, and I mean a lot. In general, what we want to do now is replace the original menu with the new one. So, look at your current theme in your browser to get a sense of where you want to make your changes, then download the header.php file from your theme and open it in your text editor, then look for something like this:

<?php wp_list_pages(); ?>

or

<?php wp_list_categories(); ?>

As can be inferred from the function names, one outputs a menu of your categories, the other shows your pages. It’s up to you which, if any, to replace with the new menu system. It’s beyond the scope of this post to show you how to style or design your new menu, especially considering the near infinite variation seen in different themes. When you decide where you want to place the new menu, you simply add this line of code to that spot:

<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

If you need help tweaking the menu statement, I strongly suggest you read the function reference in the WordPress Codex, as it will explain all the possible parameters for the function.

Of course you still need to create a new menu in your WordPress admin panel, which you do under Appearance -> Menus in the navigation on the left side of the page. The beauty of this new system is that you can personally define each link in the menu, and drag and drop them to change their order. So your first link might be a page, perhaps your About page, and the next might be a category, and the third could be an external link. The menu will use the normal page and category hierarchy for multi level menus.

Written by MidnightCoder

June 7th, 2010 at 1:12 pm

Posted in Tutorials,WordPress 3

Tagged with , , , ,

Permalink:

Shortlink:   

A New Blog, A New WordPress

leave a comment

On May 28th, WordPress.org announced the release of WordPress 3 RC1, which to anyone following the progress of WordPress 3 was very exciting. Of course, the first thing I did was grab a copy and create an installation for testing, and all I can say is WOW!

This upgrade is amazing, adding a host of new features that have been long anticipated and are sure to be well received. WordPress has long been one of the most favoured blogging and online publishing platforms available, and over the last couple years it’s also become a standard “go to” script for CMS style websites as well. The new features introduced in WordPress 3 will push it over the edge, and I can see it truly becoming “The Designer’s CMS” solution.

So what do we get in WordPress 3? Here’s the highlights:

  • WPMU is brought into the fold. Multi Site and Multi Domain self hosted WordPress is now a reality, without relying on a separate project.
  • Custom Post Types. Now with a few lines of code in your theme, you can create whole new posting screens complete with your own defined custom fields.
  • The menu system has been rewritten from the ground up. No more do we need worry about listing categories in one place, pages in another, or creating workarounds to merge them. Now you can simply choose what each link in your navigation will be, from category, page or external (or a self defined internal) link.
  • Extended Taxonomies. If you’ve ever wanted a context specific tagging system, without resorting to extraneous plugins, this is for you. By default, categories and tags are included and accessible now, but you can easily define as many new taxonomies as you need, and use them in a variety of ways throughout your theme.
  • A new default theme, called Twentyten. It’s an attractive yet neutral theme, which could be easily adapted to different uses. It also uses the HTML 5 doctype, as apparently most new themes for WordPress will use. RIP Kubrick, you had a good run, now it’s time for something a little different.
  • Shortlinks, using your own domain name. While not very pretty yet (they end in something like yourdomain.com?p=1234) it’s still a step in the right direction, and will be easy to rewrite to something more appealing.
  • And finally, a detail that has bugged WordPress designers for years has been provided for. Now there is a simple login form that can be called anywhere in the theme with a single line of code. Nice.

The last three days I’ve been digging into this new version of WordPress, and I’m just thrilled with how well it performs. So, unusually for me, I decided to adopt it early for MidnightCoder.ca and to extend the site into this blog using the new Multi Site and Domain Mapping features. It’s been flawless so far, hassle free. This version of WordPress feels so well done that it doesn’t really feel new, it’s more like waking up to find a handful of features you’ve wanted are just suddenly there and waiting. Major kudos to the WordPress team, you guys really outdid yourselves.

Written by MidnightCoder

June 6th, 2010 at 6:38 pm

Posted in News,WordPress 3

Permalink:

Shortlink: