Subdomain Multisites for WordPress – and sub-subdomain multisites

Subdomain multisites are a great way to break up a WordPress multisite. I personally think it looks much cleaner, and separate.

books.ericholmes.ca vs ericholmes.ca/books

The former(subdomain multisite) looks like a section or portion of the ericholmes.ca domain, while the latter(subfolder multisite) looks as though you are just sitting within a folder – not as professional!

The setup is actually quite simple to accomplish this. All you need to do is log into your hosting cPanel (or hosting provider equivalent) and locate where you can manage your subdomains. I use JustHost and have never regretted choosing them! Anyways, they use cPanel, so the image below is a screenshot from within cPanel.

Wildcard subdomains for subdomain multisites

It’s a pretty painless process. Once you locate your Subdomains, add the * subdomain. Then set the Home folder to the proper location (most likely /public_html/).

Wildcard Subdomain

Sub-Subdomains

This wildcard process also works for sub-subdomains as well! It’s a pretty edge-case scenario, but I ran into it (today in fact) when setting up a WP multi-site on a development server (where we use subdomains for each project).

From what I can tell (referenced in this post) wildcard subdomains on a domain level (domain.com) will also support sub-subdomain wildcards (blog.books.ericholmes.ca). Thanks to Andrea Rennick for providing this answer!

Transferring a WordPress Multisite

I have run into the situation where I needed to transfer a WordPress Multisite twice now, My first experience was horrific, but it seems I have a better handle on this now.

Step 1: Back everything up

Should be pretty self-explanatory — back up your files and database in preparation to transfer. DO NOT copy the .htaccess and wp-config.php files, it’s better practice to set these up from scratch.

Step 2: Copy the files to your new server/location

Send over your files to the new location via FTP, SSH, SVN, whatever. Create your database and set up your wp-config.php file.

Step 3: Go through WordPress installation

Before you import your database, go through the steps to set up the WP site from a clean install. Go through the steps to setting up a WPMU. This way the code you need to stick into your .htaccess and wp-config.php files will have the proper rewrite rules, as well as DOMAIN_CURRENT_SITE and PATH_CURRENT_SITE definitions.
Continue reading Transferring a WordPress Multisite

Determine if you are on the Static Posts page in WordPress

When using the Static Home Page option (and thus Static Home Page ) in WordPress, there are ways to check whether you are on the home static page, or the designated posts page.

Static Front Page

// If the current page is the blog posts index,
// but is NOT the site front page
if ( is_home() && is_front_page() ) {
    // do something
}

Continue reading Determine if you are on the Static Posts page in WordPress

Pharma Hack via MM Forms Community

Early last week, we experienced several injection attacks from something known as the “pharma hack” – this is a sneaky attack on your website, which alters the Search Engine results of your website’s pages. If you are using MM Forms Pro or MM Forms Community, I strongly recommend changing your site’s forms IMMEDIATELY.

The Signs

An easy way to check whether your site has been attacked is to do a quick Google search for your own site. Check to see if any of the pages that seem have anything funky – specifically Viagra, Cialis, or Propecia related.
Continue reading Pharma Hack via MM Forms Community

How to Get the total number of Posts in WordPress

In a recent project, I was looking to find out how many posts were in a Feedback custom post type, to display on a Dashboard widget similar to the “Right Now” Dashboard Widget that comes with WordPress.

I noticed that the only way to get a count of posts within a certain post type was using:

wp_count_posts( 'my_post_type' );

wp_count_posts() returns an object, which gives detailed information of each post status and how many posts were within that status. If you are using default post statuses, you can probably get away with this:
Continue reading How to Get the total number of Posts in WordPress