Before start working with WPMU (WordPress MultiSite)
I have done this for a Real Estate website, but it applies to any niche out there. / documentation
Install as usual
- If you would like to install WP in a directory, do it before anything else. Install WP and make sure that all permalinks works fine. Copy (not move)
index.php on site root and change:
1 2 3 4 5 |
/** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); // change to require( dirname( __FILE__ ) . '/wp-multisite-network-files/wp-blog-header.php' ); |
- It may be necessary to also change .htaccess file in the custom folder /wp-multisite-network-files/.htaccess
1 2 3 4 5 6 7 8 |
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wp-multisite-network-files/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp-multisite-network-files/index.php [L] </IfModule> |
All good? Now go ahead and activate MultiSite…
To activate MU you must copy the next line in your config.php file, nearly at the end just before any other “include” (or “require”).
1 2 |
/* MultiSite */ define( 'WP_ALLOW_MULTISITE', true ); |
OK, now you will find under “Tools” a link to create a “Network”. Here is where you will setup MultiSite. Just follow the on screen instruction.
Just for security sake, it is a good practice to change the wp-content folder path min WP site. You can. So let’s do this small change ( documentation )
1 2 |
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/custom-files/wp-content' ); define( 'WP_CONTENT_URL', '/wp-multisite-network-files/custom-files/wp-content' ); |
You notice that we buried a little bit the user content folder. This is very useful when fighting against SPAM and “bad robots”
Ok That’s all…Now lets start playing with some MU compatible Plugins
Install MultiSite Clone Duplicator. A little bit redundant…but he´ll do the job well. You can use this plugin to specify a default website
to duplicate the content from. This way you only have to apply all settings once. This is what he´s author says about the plugin: “ Clones an existing site into a new one in a multisite installation : copies all the posts, settings and files”
Like me, you may be interested in hiding this plugin from child-sites. So you can go search for a plugin to do that, or you can just use standard WordPress hook, like this:
1 2 3 4 5 6 7 8 |
function hide_site_plugins_on_child_sites($plugins){ unset($plugins['multisite-clone-duplicator/multisite-clone-duplicator.php']); // unset($plugins['akismet/akismet.php']); return $plugins; } add_filter('all_plugins','hide_site_plugins_on_child_sites', 12, 1); |
If you like to hide some more plugins and you do not know the path, just do a var_dump($plugins). Or if you prefer:
1 2 3 |
echo "<pre>"; print_r($var); echo "</pre>"; |
Another small thing when developing WP sites is that you have to deal with the WP toolbar when logged in. Here is the simplest way to hide admin bar on WordPress sites.
1 2 3 4 5 |
/* * Hide admin bar on user logged in. * Don't you just love the power of WP hooks :) */ add_filter('show_admin_bar', '__return_false'); |
Install Revolution Slider and create some sliders. I used same slider on all pages and set it to start with a random slide. This way it
looks different on navigation.
I used a custom-made function to add a meta box on all edit.php for all pages. This meta box contains a small select, so that the use can choose a slider
to display in the page header.
Install Visual Composer and enable this for all sites. This is pretty cool to create static content pages for non-coding users.
Use Advanced Custom Fields to add some custom fields for posts (which I customized and used as a custom post type).
Install Contact Form 7 for the contact form on contact page. I needed to post the data on a different URL that I already had, so I used
this next wp_filter to change posting to another URL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* * change action url of the form * just atach function to the "wpcf7_form_action_url" contact form 7 filter */ add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url'); function wpcf7_custom_form_action_url($url) { global $post, $wpcf7; // CHANGE THE POST ID HERE if ($post->ID === 434) { $wpcf7->skip_mail = 1; // stop email from being sent (optional) return '/wp-content/themes/mytheme/refresh.php'; } else { return $url; } } |
I will continue playing with WordPress MU in the next tutorials, but this is all for today. Please let me know your experience with it.