0

I have a weird issue right now on one of our sites. We switched from a subdomain multisite install to a subfolder install for our staging site setup. So all urls went from this:

site.website.com

to this

staging.otherwebsite.com/site

The problem is that Wordpress doesn't seem to recognize the other sites titles and links. It shows 10 sites but they all have the same info as the main blog (same title and same link to dashboard edit screens).

Some things I have tried were changing the config file to support subfolder multisites:

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'staging.otherwebsite.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

I have also had to change the database tables as well. I went in and changed the path columns for each site in the wp_blogs table so it matches to correct structure. I think I also did the same for the wp_site table as well.

My htaccess file looks like below:

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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

What could be causing the issue where wordpress displays all sites in the menu as if they all had the same title and link (basically showing the main site 10 times which is the same amount of sites I have)? Is there any steps I missed when switching a subdomain install to to a subfolder install? If there is any additional info I can provide let me know and I will add it.

Thanks

UPDATE

I posted an answer but it doesn't work...fully. It solves it temporarily. When I call this function before calling the get_blog_details function.

Now here is the weird part, when I add this function wp_cache_flush() before looping through each blog id, the get_blog_details() function returns the same blog details.

When I add the cache flush inside the loop before I get blog details, I get the proper blog details for each one. When I remove the flush function the problem returns.

I am researching this as I go along to see why this is. Any details on this will help me out big time.

1

After diving deep into wordpress core files I found out that somewhere along the lines of getting the blog details was a caching function.

It was this line in the ms-blogs.php file.

$details = wp_cache_get( $blog_id . $all, 'blog-details' );

It turns out that I had a cached version of the blog details which messed some things up from the previous install. I checked the wp-config.php file and I did have W3 cache enabled. I temporarily fixed it by doing a flush. I added this code.

global $wp_object_cache;
$wp_object_cache->flush();

After page reloaded I noticed the blog details were showing correctly.

Update

Ok So I think I fixed it for real this time. I disabled the w3 cache plugin but it didn't work for me so I thought the issue stemmed from somewhere else. I went into the plugins folder after many trial and errors and just decided to rename the w3cache plugin folder to something else. That apparently fixed the issue. I guess something was still referencing the plugin despite it being disabled through Wordpress.

The files advanced-cache.php and object-cache.php need to be removed to stop referencing the w3caching plugin.

You can add the plugin again and it may work the second time around.

Just wanted to share that as it drove me nuts for a while.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.