Хей, имам нещо специално за теб!

5 грешки, които допускаш по време на интервю

Попълни имейл адрес, на който до минута ще получиш обещаното ;)

Creating a WordPress Network – in three steps ?️

A WordPress network environment allows you to have a main website where you can have installations of the CMS, or in other words, child websites. There are many pros and cons, so it’s important to consider them before opting for such a solution. The most common reason for having a network is the ability to administer multiple websites under one “umbrella” (e.g., online stores for different countries, blogs in different languages, etc.).

The child websites have access to all installed themes and plugins in the network, but each of them has its own separate content.

With the explanation of what WordPress Network represents, I assume that if you’re reading this post, you are already familiar with it, and what you are looking for is specifically…

How to configure WordPress for a network

Here is the answer:

This is a built-in functionality of WordPress, and the only thing you need to do is add the following two lines to the wp-config.php file, after the line /* That’s all, stop editing! Happy blogging. */:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);

What the code does is simply activate the WordPress multisite functionality. After adding and saving it in the wp-config.php file, there are a few more steps to follow:

  • Go to the administration of your site, specifically to the “Plugins” section, and deactivate all plugins.
  • Then, in the “Tools” menu, you will see a new submenu called “Network setup.” Open it and choose whether your child sites should be created as subdirectories or subdomains (e.g., www.mysite.com/site-1 or www.site-1.mysite.com).
  • The third step is to copy and paste the generated lines of code into the respective files: .htaccess and wp-config.php. Here’s an example of how they may look:
// wp-config.php
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
define( 'DOMAIN_CURRENT_SITE', 'yourprimarydomain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
    // .htaccess
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [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).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    With these changes, you are essentially informing WordPress about the domains you want to use and overriding the previous settings in the .htaccess file.

    That’s it! You can now log back into your network administration and start creating child sites.

    Stay blond 😉

    Leave a Reply

    Your email address will not be published. Required fields are marked *